Actually, I had declared gInstance as a variable of ttype Context and
not of type JakesApplication.  I guess both are correct except that
JakesApplication is more type-specific and better programming style?

>>>>> "MM" == Mark Murphy <[email protected]> writes:

   MM> Oh, I see where you're going. Yeah, that should be OK. I've often
   MM> wondered why they didn't bother with a static getter on
   MM> Application itself, if the thing is going to live as long as a
   MM> static.

   MM> On Mon, Mar 28, 2011 at 10:10 AM, Kostya Vasilyev <[email protected]> 
wrote:
   >> 28.03.2011 17:59, Jake Colman пишет:
   >>> 
   >>> Does extending the Application class to save the context and providing a
   >>> static method to access that context an appropriate solution as well?
   >> 
   >> I don't see any problems with:
   >> 
   >> class JakesApplication extends Application /* indirectly extends Context 
*/
   >> {
   >> 
   >> @Override
   >> public void onCreate() {
   >> super.onCreate();
   >> gInstance = this;
   >> }
   >> 
   >> public static JakesApplication getInstance() {
   >> return gInstance;
   >> }
   >> 
   >> private JakesApplication gInstance;
   >> }
   >> 
   >> --
   >> Kostya Vasilyev -- http://kmansoft.wordpress.com
   >> 
   >> --
   >> You received this message because you are subscribed to the Google
   >> Groups "Android Developers" group.
   >> To post to this group, send email to [email protected]
   >> To unsubscribe from this group, send email to
   >> [email protected]
   >> For more options, visit this group at
   >> http://groups.google.com/group/android-developers?hl=en
   >> 

   MM> -- 
   MM> Mark Murphy (a Commons Guy)
   MM> http://commonsware.com | http://github.com/commonsguy
   MM> http://commonsware.com/blog | http://twitter.com/commonsguy

   MM> Android Training in NYC: http://marakana.com/training/android/

   MM> -- 
   MM> You received this message because you are subscribed to the Google
   MM> Groups "Android Developers" group.
   MM> To post to this group, send email to [email protected]
   MM> To unsubscribe from this group, send email to
   MM> [email protected]
   MM> For more options, visit this group at
   MM> http://groups.google.com/group/android-developers?hl=en

-- 
Jake Colman -- Android Tinkerer

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to