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
Post a Comment