在Android开发的过程中,有时候要判断某个Activity时候再最上层,这里有个方法,大家可以参考
public static boolean isTopActivity(Activity activity) { ActivityManager am = (ActivityManager)activity.getSystemService(ACTIVITY_SERVICE); ComponentName cn = am.getRunningTasks(1).get(0).topActivity; return cn.getClassName().contains(activity.getLocalClassName()); }
标签:
android