简体   繁体   English

如何知道哪个应用程序在后台运行

[英]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. 你可以检查,如果类型你想找到一个特定的一个,你使用它的全名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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