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