I don’t see intent variable getting declared anywhere in CheatActivity file. Does it mean it’s always available on every activity subclass? Can someone also point me to documentation showing all default properties/fields of an activity?
Every Activity is started via an Intent, whether that Intent is created by another Activity (QuizActivity in this instance) or by the operating system.
Therefore, the Activity object can reference the Intent that was used to create the Activity. This is done by calling the getIntent() method. The Kotlin syntax allows us to just reference the value we wish to get, here intent, and the compiler converts the request in to the corresponding getter.
Yes, Because of Kotlin’s feature of getters and setters,
Using intent property works well.
But I think the following code is easier to understand,
because many people may be wondering “What is intent?”.