Top "Android-context" questions

Interface to global information about an application environment

Static way to get 'Context' in Android?

Is there a way to get the current Context instance inside a static method? I'm looking for that way because …

android android-context
What is 'Context' on Android?

In Android programming, what exactly is a Context class and what is it used for? I read about it on …

android android-context
Using context in a fragment

How can I get the context in a fragment? I need to use my database whose constructor takes in the …

java android android-fragments android-context
Dialog throwing "Unable to add window — token null is not for an application” with getApplication() as context

My Activity is trying to create an AlertDialog which requires a Context as a parameter. This works as expected if …

android android-alertdialog android-context builder
How to get package name from anywhere?

I am aware of the availability of Context.getApplicationContext() and View.getContext(), through which I can actually call Context.getPackageName() …

android package android-context
getApplication() vs. getApplicationContext()

I couldn't find a satisfying answer to this, so here we go: what's the deal with Activity/Service.getApplication() and …

android android-activity android-service android-context
Using Application context everywhere?

In an Android app, is there anything wrong with the following approach: public class MyApp extends android.app.Application { private …

android android-context
Difference between getContext() , getApplicationContext() , getBaseContext() and "this"

What is the difference between getContext() , getApplicationContext() , getBaseContext() , and "this"? Though this is simple question I am unable to understand …

android this android-context
Calling startActivity() from outside of an Activity context

I have implemented a ListView in my Android application. I bind to this ListView using a custom subclass of the …

android android-activity android-context
How to get my activity context?

I don't really get the idea behind how this whole thing works really, so if I have some class A …

android android-context