[android-developers] Re: Application context

2009-10-09 Thread Gopal Biyani
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  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 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
-~--~~~~--~~--~--~---



[android-developers] Re: Application context

2009-10-08 Thread Mark Murphy

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 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
-~--~~~~--~~--~--~---



[android-developers] Re: Application Context

2008-12-04 Thread Dianne Hackborn
Nope, there is no current context.  You need to explicitly supply the
context.

On Wed, Dec 3, 2008 at 4:02 PM, Cezar Augustus Signori <
[EMAIL PROTECTED]> wrote:

>
> Hi!
>
> It would be pretty good to obtain the application context from a
> static method, without the use of an Activity object.
>
> I mean, there is a lot of frameworks that do it and its really very
> useful..
>
> Something like Context.getCurrentInstance() would help a lot..
>
> Someone know anything about that on Android?
>
> Thanks!
> >
>


-- 
Dianne Hackborn
Android framework engineer
[EMAIL PROTECTED]

Note: please don't send private questions to me, as I don't have time to
provide private support.  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
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---