试图获取Android中所有正在运行的任务吗? [英] Trying to fetch all running tasks in android?

查看:124
本文介绍了试图获取Android中所有正在运行的任务吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获取所有当前正在运行的应用程序,我试图做到这一点是这样的:

I am trying to fetch all the currently running apps and i am trying to do it like this:

try
{
    List<ActivityManager.RunningAppProcessInfo> tasks = am.getRunningAppProcesses();
}
catch (SecurityException e)
{
   //Something
}

但每次我试图在模拟器它给我强制关闭错误信息运行它。

But every time i am trying to run it on emulator it's giving me force close error message.

推荐答案

它需要的权限在AndroidManifest.xml中设置:

It need permission to be set in the AndroidManifest.xml:

<uses-permission android:name="android.permission.GET_TASKS" />

这篇关于试图获取Android中所有正在运行的任务吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆