I guess a better way to phrase my question: Is Application always accessible as a singleton?
If it isn't what are the cases I need to watch out for? If it is what was the reasoning of making it difficult to reach from other contexts? On Wednesday, July 16, 2014 11:39:54 AM UTC-7, peter wrote: > > Recently had to fix a bug where we had Toast's being created against > activity from Async tasks. Looking at the docs it looks like we should > have used ApplicationContext instead of Activties. > > I am unaware of any instance where there is more than 1 Application. In > what situation during the lifecycle accessible via Android code do I need > to treat Application as a not-singleton? > > More explicitly, Is it safe to treat Application as a singleton? I.E. in > fragment.onAttach() grab a local reference the > activity.getApplicationContext() and assume that it will ALWAYS return the > same object. > > If Application is a singleton what is the reasoning for making it > inaccessible to fragments? > -- 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 --- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

