Android examples for Activity:Activity Status
is Activity Front
//package com.java2s; import android.app.ActivityManager; import android.content.Context; import java.util.List; public class Main { public static boolean isActivityFront(Context context, String className) { ActivityManager mActivityManager = (ActivityManager) context .getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasksInfo = mActivityManager .getRunningTasks(1);//from w w w. jav a 2 s. com if (tasksInfo.size() > 0) { if (className.equals(tasksInfo.get(0).topActivity .getPackageName())) { return true; } } return false; } }