List of usage examples for android.app ActivityManager getRunningTasks
@Deprecated public List<RunningTaskInfo> getRunningTasks(int maxNum) throws SecurityException
From source file:Main.java
private static String getLower(ActivityManager mActivityManager) { return mActivityManager.getRunningTasks(1).get(0).topActivity.getPackageName(); }
From source file:Main.java
public static String getTopActName(Context ctx) { ActivityManager am = (ActivityManager) ctx.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; String clsName = cn.getClassName(); return clsName; }
From source file:Main.java
public static boolean isAppRunningForeground(Context context) { ActivityManager var1 = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); List list = var1.getRunningTasks(1); return context.getPackageName() .equalsIgnoreCase(((ActivityManager.RunningTaskInfo) list.get(0)).baseActivity.getPackageName()); }
From source file:Main.java
public static String getRunningActivityName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return activityManager.getRunningTasks(1).get(0).topActivity.getClassName(); }
From source file:Main.java
@SuppressWarnings("deprecation") public static String getRunningActivityName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return activityManager.getRunningTasks(1).get(0).topActivity.getClassName(); }
From source file:Main.java
public static String getCurrentActivityPkgName(Context context) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; // String className=cn.getClassName(); return cn.getPackageName(); }
From source file:Main.java
public static boolean isTopActivy(Context context, String activityName) { ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cName = am.getRunningTasks(1).size() > 0 ? am.getRunningTasks(1).get(0).topActivity : null; if (null == cName) return false; return cName.getClassName().equals(activityName); }
From source file:Main.java
public static String getTopActivityClassName(Context context) { try {// w w w.ja v a2s . c om ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getClassName(); } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static String getRunningActivityName(Context context) { ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); String runningActivity = activityManager.getRunningTasks(1).get(0).topActivity.getClassName(); return runningActivity; }
From source file:Main.java
@Nullable public static String getCurrentRunningActivityPackage(@NonNull Context context) { try {//from w ww . j av a 2 s. com ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE); return am.getRunningTasks(1).get(0).topActivity.getPackageName(); } catch (Exception e) { /* sad, but true */ } return null; }