Search in sources :

Example 26 with RunningTaskInfo

use of android.app.ActivityManager.RunningTaskInfo in project SmartCampus by Vegen.

the class EaseCommonUtils method getTopActivity.

/**
 * get top activity
 * @param context
 * @return
 */
public static String getTopActivity(Context context) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<RunningTaskInfo> runningTaskInfos = manager.getRunningTasks(1);
    if (runningTaskInfos != null)
        return runningTaskInfos.get(0).topActivity.getClassName();
    else
        return "";
}
Also used : ActivityManager(android.app.ActivityManager) RunningTaskInfo(android.app.ActivityManager.RunningTaskInfo)

Aggregations

RunningTaskInfo (android.app.ActivityManager.RunningTaskInfo)26 ActivityManager (android.app.ActivityManager)13 ComponentName (android.content.ComponentName)11 Point (android.graphics.Point)7 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 RemoteException (android.os.RemoteException)5 ArrayList (java.util.ArrayList)2 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1