I’m trying to show an alert dialog with my application from a non-activity.
So the hard thing here is that I want to do it not in an activity but in my general application class.
public class AppName extends com.github.droidfu.DroidFuApplication {
public static long TIME_CONTENT_UPDATE = 60; //half hour
Handler mHandler = new Handler();
@Override
public void onCreate() {
super.onCreate();
intent = new Intent(this, VSSyncController.class);
setupTimer();
}
private void setupCatalogTimer() {
final Context con = this;
//A handler runs on a separate thread
mHandler = new Handler(new Handler.Callback() {
public boolean handleMessage(Message msg) {
showMyAlertDialog(con)
mHandler.sendEmptyMessageDelayed(0, TIME_CONTENT_UPDATE);
return true;
}
});
}
}
Basically I want to show an alert dialog from there, but I need to have a way to figure out which and IF there is any activity in the foreground, so I can call it from there.
How can I possible do it?
Thanks!
Thinking out of the box what I did was send a notification (when the dialog was suppose to pop) that takes the user back to the activity and there it shows the dialog!
This way we don’t deal with the problem to check which activity is not in front.