java - how to check if my app is on the foreground? -


this question has answer here:

i'm running android app.

i want enable push notifications when app not visible

(closed or in background).

i have seen code:

  activitymanager activitymanager = (activitymanager) this.getsystemservice( activity_service );     list<runningappprocessinfo> procinfos = actvitymanager.getrunningappprocesses();     for(int = 0; < procinfos.size(); i++){         if(procinfos.get(i).processname.equals("com.android.browser")) {             toast.maketext(getapplicationcontext(), "browser running", toast.length_long).show();         }     } 

for checking if browser on,

but it's not enough me check if process on,

it can running not visible @ moment,

and want notifications show in case oppose when it's visible.

the approach follow in case :

make service post notifications. , onstart() or onresume() ,stop service , onpause() or onstop() ,start service again.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -