Instead of getApplicationContext()
, just use ActivityName.this
.
More Related Contents:
- Why does AlertDialog.Builder(Context context) only accepts Activity as a parameter?
- What is ‘Context’ on Android?
- When to call activity context OR application context?
- How to prevent a dialog from closing when a button is clicked
- Using Application context everywhere?
- How do I display an alert dialog on Android?
- What’s the difference between the various methods to get an Android Context?
- Difference between Activity Context and Application Context
- How to get package name from anywhere?
- Calling startActivity() from outside of an Activity context
- How can I change the color of AlertDialog title and the color of the line under it
- What’s “tools:context” in Android layout files?
- Using getResources() in non-activity class
- How to display a Yes/No dialog box on Android?
- getting context in AsyncTask
- Transparent AlertDialog has black background
- get Context in non-Activity class [duplicate]
- android activity has leaked window com.android.internal.policy.impl.phonewindow$decorview Issue
- How to put an image in an AlertDialog? Android
- How to use Dialog Fragment? (showDialog deprecated) Android
- Why getApplicationContext() in constructor of Activity throws null pointer exception?
- Get context inside onClick(DialogInterface v, int buttonId)?
- Dagger 2 injecting Android Application Context
- How to dismiss AlertDialog in android
- Android simple alert dialog [duplicate]
- How to call getResources() from a class which has no context?
- Changing font size into an AlertDialog
- Getting the Application Context
- How to change alert dialog header divider color android
- Change the background color of a pop-up dialog