I am displaying a pop up from Notification of my application.But when I check my notification no activity is running from my application so in notification when I show dialogue
You may create MyApplication
class, inherited from the Application
, then inside that class do the following:
public class MyApplication extends Application {
private static MyApplication instance;
@Override
public void onCreate() {
super.onCreate();
instance = this;
.........
}
public static Context getContext() {
return instance;
}
After that, you may use MyApplication.getContext()
anywhere if you need a context and don't have an Activity
lying around.