安卓判断某种APP是否在运行
public static boolean isRunning(Context context, String packageName) {
ActivityManager am = (ActivityManager) context
.getSystemService(Context.ACTIVITY_SERVICE);
List<RunningAppProcessInfo> list = am.getRunningAppProcesses();
for (RunningAppProcessInfo appProcess : list) {
String processName = appProcess.processName;
if (processName != null && processName.equals(packageName)) {
return true;
}
}
return false;
}