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
I would assume that your code is running in a background in an Android Service
. If that's the case, your Service
is a Context
itself, so you can use it when you need one.
Of your code is running in a background thread and not in an Android Service
(in which case you have other big problems), you could use an instance of the application context. You get one though calling Context.getApplicationContext, and you can get it in the Activity
that starts your background code and cache it for later.
Note though that there are certain gotchas with using application context, instead of activity context - for example, you can't use LayoutInflater
from application context.