android - Is it possible to know whether another app is in background or foreground? -


i'm going develop task manager app.

but before starting, want know app can detect other applications status or not? example in running background or in foreground?

does android system provide methods determine this?

firstly, afaik, @ time, 1 application can in foreground mode. means, if run application (task manager), in foreground mode , other application running in background mode until being killed. don't have list out foreground application list.

to running (current application in foreground , others background)application list, can use following codes:

activitymanager actvitymanager = (activitymanager) this.getsystemservice( activity_service ); list<runningappprocessinfo> procinfos = actvitymanager.getrunningappprocesses(); 

nevertheless, know application in foreground can use following codes after above codes:

for(runningappprocessinfo appprocess : appprocesses){     if(appprocess.importance == runningappprocessinfo.importance_foreground){         log.i("foreground app", appprocess.processname);     } } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -