简体   繁体   中英

How to know which application is running in background

Thanks for previous replies,

Is it possible to know which are the applications running in background process.My query is to get the list of applications which is running in background. I searched this for a while, but still dint get any proper solution. pls guide me.

You can get a list of services running using this sort of code:

private boolean isMyServiceRunning(Context context)
{
    ActivityManager manager = (ActivityManager) context.getSystemService(Service.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE))
    {           
        if (service.service.getClassName().equals("myPackage.MySuperApplication"))
        {               
            return true;
        }
    }
    return false;
}

There are a whole bunch of Service. types that you can check for and if you want to find a specific one, you use its fully qualified name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM