If you want to call getApplicationContext in your Foo class, it better to pass Context reference as a parameter in method DoSomethingWithCurrentContext() or you can pass in constructor while instantiating the Foo class. I think there is no other way to access the context object.
On Thu, Oct 8, 2009 at 8:16 PM, Mark Murphy <[email protected]> wrote: > > Phillip wrote: > > I'm trying to retrieve the current application's context indirectly > > from an object that my application uses. For example, I have a MyApp > > class that extends Activity which itself extends Context. From within > > MyApp I declare a variable of type Foo, where Foo is a utility class I > > define for whatever purpose. Is there any way for > > DoSomethingWithCurrentContext() to retrieve MyApp's context without > > explicitly passing the context into it as a parameter using > > getApplicationContext()? > > There is no such thing as "current context", unless you track that > yourself. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > _Android Programming Tutorials_ Version 1.0 Available! > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

