Example usage for android.app ActivityManager moveTaskToFront

List of usage examples for android.app ActivityManager moveTaskToFront

Introduction

In this page you can find the example usage for android.app ActivityManager moveTaskToFront.

Prototype

@RequiresPermission(android.Manifest.permission.REORDER_TASKS)
public void moveTaskToFront(int taskId, @MoveTaskFlags int flags) 

Source Link

Document

Equivalent to calling #moveTaskToFront(int,int,Bundle) with a null options argument.

Usage

From source file:Main.java

public static void moveTaskToFront(Context context, int taskId) {
    ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    am.moveTaskToFront(taskId, ActivityManager.MOVE_TASK_WITH_HOME);
}

From source file:Main.java

public static void blockRecentApps(Activity activity) {
    ActivityManager activityManager = (ActivityManager) activity.getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.moveTaskToFront(activity.getTaskId(), 0);
}

From source file:Main.java

public static void disableRecentAppsClick(Activity activity) {
    ActivityManager activityManager = (ActivityManager) activity.getApplicationContext()
            .getSystemService(Context.ACTIVITY_SERVICE);
    activityManager.moveTaskToFront(activity.getTaskId(), 0);
}

From source file:uk.org.ngo.squeezer.framework.BaseActivity.java

@Override
@TargetApi(Build.VERSION_CODES.KITKAT)//ww  w.  java2s  .c o m
public void finish() {
    super.finish();
    if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT && !isTaskRoot() && mIsRestoredToTop) {
        // 4.4.2 platform issues for FLAG_ACTIVITY_REORDER_TO_FRONT,
        // reordered activity back press will go to home unexpectedly,
        // Workaround: move reordered activity current task to front when it's finished.
        ActivityManager tasksManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
        tasksManager.moveTaskToFront(getTaskId(), ActivityManager.MOVE_TASK_NO_USER_ACTION);
    }
}