hi Dianne, thanks for the reply... I think the name ApplicationContext is slightly misleading. Because the ApplicationContext object acts as a Base Context object which gets stored in ContextWrapper / ContextThemeWrapper
Whereas when I call myActivity.getApplicaitonContext, I actually get the application object. in ApplicationContext.java @Override public Context getApplicationContext() { return mMainThread.getApplication(); } So what gets created as Application context is actually a base context and what actually is returned when getApplicationContext is the mInitialApplicaiton object. Cause of Confusion: The reason why i felt this leads to confusion (for someone who is reading the code not to someone who is using the API) is because, the javadoc for getApplicaitonContext says that there is only one ApplicaitonContext object for the entire applicaiton (which is obtained by calling getApplicationContext). WHEREAS each activity in an application can have its own ApplicationContext object (which is mBase). So 2 entirely different objects have been named with the same name : ApplicationContext. Regards, Amitkeerti On Sep 29, 10:59 pm, Dianne Hackborn <hack...@android.com> wrote: > ApplicationContext is private implementation. Activity takes care of the > startActivity implementation for itself, since it wants the starting > activity to be associated with the original activity (and ApplicationContext > is just the most generic context, which doesn't know that it is an > activity). > > > > On Tue, Sep 29, 2009 at 12:49 AM, amit <amitkee...@gmail.com> wrote: > > > hi, > > > I was going through the code for Activity.java and ApplicationContext. > > > Both these classes define many functions of Context Interface. Take > > for example startActivity.java > > > Activity Class has its own implementation of startActivity > > ApplicationContext class also has an implemenetaion of startActivity. > > > Now there are 2 observations... > > > Observation 1: Regarding ApplicationContext.java > > > ==================== > > /** > > * Common implementation of Context API, which Activity and other > > application > > * classes inherit. > > */ > > @SuppressWarnings({"EmptyCatchBlock"}) > > class ApplicationContext extends Context { > > =================================== > > > So the comments imply that Activity class should actually use > > ApplicaitonContext.java. Infact Activity Class should inherit > > ApplicationContext class. > > > Observation 2: Regarding Activity.java > > > But if you look at class Hierarchy of Activity class, it goes as: > > > Context ==> ContextWrapper ==> ContextThemeWrapper ==> Activity > > > So nowhere do I find ApplicationContext. > > > Questions: > > 1. Who uses ApplicationContext class? > > 2. Does Activity class ever deal with ApplicationContext class (as > > given in the javadoc comments of ApplicationContext.java). > > > Thanks, > > Amit > > -- > Dianne Hackborn > Android framework engineer > hack...@android.com > > Note: please don't send private questions to me, as I don't have time to > provide private support, and so won't reply to such e-mails. All such > questions should be posted on public forums, where I and others can see and > answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---