• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

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: 26747
190
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!
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic