判断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" />

 

上一篇:Android如何防止apk程序被反编译


下一篇:面试必知道的APP测试adb命令