In your main activity you can create something like this

Context context = this;

Then you can pass the context object to any other methods that need it
as a parameter.

On May 15, 9:41 am, SGAdrian <[email protected]> wrote:
> Sorry but I dont get it.
>
> I am starting my java program with app_process, i.e I am not running
> any Service or Activity. Just like the Monkey.java program is doing.
>
> Ex.
>
> public class Main {
>         public static void main(String[] args) {
>                // How can I get hold of a Context instance here?
>                //
>        }
>
> }
>
> BR,
> Sven
>
> On May 15, 2:50 pm, "Mark Murphy" <[email protected]> wrote:
>
> > > When you are developing on an application level(Services, Activities)
> > > you always get this Context reference automatically.
>
> > > But what if I am on a lower level and developing a program started
> > > with app_process, how can I get hold of a Context then? Its a huge
> > > part of the API that need this context.
>
> > Have it passed to you via the API to your lower level. In other words,
> > just as the Android API requires you to pass in a Context, your API to
> > your higher levels will require those higher levels to pass in a Context.
>
> > > What the proper way to create a Context instance?
>
> > AFAIK, you don't create Context instances -- you use the ones created for
> > you by Android (e.g., Activity, Service).
>
> > --
> > Mark Murphy (a Commons Guy)http://commonsware.com
> > _The Busy Coder's Guide to Android Development_ Version 2.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
-~----------~----~----~----~------~----~------~--~---

Reply via email to