2

您好我有兴趣启动一个任务杀手应用程序,但想知道您是否以及如何查看手机上运行的当前应用程序。

4

1 回答 1

2

尝试使用ActivityManager

try
{
    List<ActivityManager.RunningAppProcessInfo> tasks = am.getRunningAppProcesses();
    int numOfTasks = tasks.size();
    for(int i = 0; i < numOfTasks; i++)
    {
        ActivityManager.RunningAppProcessInfo task = tasks.get(i);
        try
        {
            PackageInfo myPInfo = getPackageManager().getPackageInfo(task.processName, 0);
            //System.out.println(task.processName);
        }
        catch (PackageManager.NameNotFoundException ne)
        {
         ne.printStackTrace();
        }
    }
}
catch (SecurityException se)
{
 se.printStackTrace();
}

另见:http ://smartandroidians.blogspot.com/2011/05/way-to-check-whether-application-is.html

于 2012-08-06T19:36:13.017 回答