In android java we hear a word all the time, right from the first “hello world” creation, in fact 2 words, Activity and Context. As we know everything on android platform is an activity. Everything that changes your screen UI by a simple pixel is an activity. Even when your G1 boots up you are fore-mostly represented with a desktop-wallpaper setting holding a few icons and widgets, which is nothing else but a big activity holding many similar but smaller activities. A look into the logcat can determine it while the emulator boots up…………

So far so good, but what about context, well for the word wise context is nothing else but an environment/surroundings where your application runs. A context will define/outline the necessary info about the app. and its environment and here’s the interesting part, your activity itself is nothing else but “is-a”(??……..the father and the child…….remember something) Context. A close look at the Activity class will tell you………….

Activity

extends ContextThemeWrapper which in turn extends from context itself. But hark…………..context is a very generalized definition for an activity………activity is a context and its more than that(generalization and specilization). So the activity manager simply creates the the object of the activity/context to call your onCreate() and all the other activity class methods.

Some more info on Context can be found at:

http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html

Advertisements