• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getIntent() mystery

 
Matthew Vahedi
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Can you please explain how it is possible to call getIntent() method without using class name? I don't see any Static import or static method declaration!



Thank you.
 
Tim Holloway
Saloon Keeper
Posts: 18362
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getIntent() is a member function of the Activity class. When you invoke it, the current class instance is referenced to return the Intent that activated it.

The following code elements do exactly the same thing as your example:



The second example works because your Activity is a subclass of android.app.Activity and it's that parent class that actually implements the getIntent() method. The first example is based on the idea that:


is implicitly defined by Java's inheritance mechanism. Assuming you don't override it with some other functionality, anyway!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic