Top "Android-context" questions

Interface to global information about an application environment

How to call getResources() from a class which has no context?

In my application I have many classes and activities. Droid is a class which does not have context. Mygame is …

android class background android-context
How to get a context in a recycler view adapter

I'm trying to use picasso library to be able to load url to imageView, but I'm not able to get …

java android android-recyclerview picasso android-context
android - How to get view from context?

I want to get the view or findViewById() from Context? Or from intent? I'm trying to reach a specific view …

android android-intent broadcastreceiver android-context
How to display AlertDialog in a Fragment?

I want to display an alert dialog in my app. I am using fragments. I tried the below code to …

java android fragment android-alertdialog android-context
How to reference the current or main activity from another class

I often find myself needing to access methods that require referencing some activity. For example, to use getWindowManager, I need …

android android-activity android-context
What's the difference between the various methods to get a Context?

In various bits of Android code I've seen: public class MyActivity extends Activity { public void method() { mContext = this; // since Activity …

android android-context
How to use getSystemService in a non-activity class?

I am building an application which triggers an alarm via AlarmManager. I would like to be able to call the …

android android-context
Get context inside onClick(DialogInterface v, int buttonId)?

Getting the context inside onClick(View view), the callback for a button's onClickListener(), is easy: view.getContext() But I can't …

android dialog onclick android-context
When to call activity context OR application context?

There has been a lot of posting about what these two contexts are.. But I'm still not getting it quite …

android this android-context
Android: why must use getBaseContext() instead of this

this often to reference to current context. But, at some case, why we must use getBaseContext() instead of this. (It …

android this android-context