• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getIntent() mystery

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27708
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic