判断APK是否在运行
作者:互联网
public static boolean isRunning(Context mContext, String packageName)
{
try {
ActivityManager manager = (ActivityManager) mContext
.getSystemService(Context.ACTIVITY_SERVICE);
RunningTaskInfo info = manager.getRunningTasks(1).get(0);
String packageName = info.topActivity.getPackageName();
return packageName.equals(packageName);
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
<uses-permission android:name="android.permission.GET_TASKS" />
标签:mContext,ActivityManager,return,String,packageName,APK,manager,判断,运行 来源: https://blog.51cto.com/u_15298588/3034190