Search in sources :

Example 16 with AppTask

use of android.app.ActivityManager.AppTask in project AndroidChromium by JackyAndroid.

the class MultiWindowUtils method isActivityTaskInRecents.

/**
 * @param className The class name of the Activity to look for in Android recents
 * @param context The current Context, used to retrieve the ActivityManager system service.
 * @return True if the Activity still has a task in Android recents, regardless of whether
 *         the Activity has been destroyed.
 */
@TargetApi(Build.VERSION_CODES.M)
private boolean isActivityTaskInRecents(String className, Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<AppTask> appTasks = activityManager.getAppTasks();
    for (AppTask task : appTasks) {
        if (task.getTaskInfo() == null || task.getTaskInfo().baseActivity == null)
            continue;
        String baseActivity = task.getTaskInfo().baseActivity.getClassName();
        if (TextUtils.equals(baseActivity, className))
            return true;
    }
    return false;
}
Also used : AppTask(android.app.ActivityManager.AppTask) ActivityManager(android.app.ActivityManager) TargetApi(android.annotation.TargetApi)

Example 17 with AppTask

use of android.app.ActivityManager.AppTask in project platform_packages_apps_Settings by BlissRoms.

the class ChooseLockGenericTest method finishAllAppTasks.

private void finishAllAppTasks() {
    final ActivityManager activityManager = getTargetContext().getSystemService(ActivityManager.class);
    final List<AppTask> appTasks = activityManager.getAppTasks();
    for (ActivityManager.AppTask task : appTasks) {
        task.finishAndRemoveTask();
    }
}
Also used : AppTask(android.app.ActivityManager.AppTask) AppTask(android.app.ActivityManager.AppTask) ActivityManager(android.app.ActivityManager)

Example 18 with AppTask

use of android.app.ActivityManager.AppTask in project robolectric by robolectric.

the class ShadowAppTaskTest method finishAndRemoveTask_marksTaskFinished.

@Test
public void finishAndRemoveTask_marksTaskFinished() {
    final AppTask appTask = ShadowAppTask.newInstance();
    appTask.finishAndRemoveTask();
    assertThat(shadowOf(appTask).isFinishedAndRemoved()).isTrue();
}
Also used : AppTask(android.app.ActivityManager.AppTask) Test(org.junit.Test)

Example 19 with AppTask

use of android.app.ActivityManager.AppTask in project robolectric by robolectric.

the class ShadowAppTaskTest method moveToFront_movesTaskToFront.

@Test
public void moveToFront_movesTaskToFront() {
    final AppTask appTask = ShadowAppTask.newInstance();
    appTask.moveToFront();
    assertThat(shadowOf(appTask).hasMovedToFront()).isTrue();
}
Also used : AppTask(android.app.ActivityManager.AppTask) Test(org.junit.Test)

Example 20 with AppTask

use of android.app.ActivityManager.AppTask in project robolectric by robolectric.

the class ShadowAppTaskTest method getTaskInfo_returnsCorrectValue.

@Test
public void getTaskInfo_returnsCorrectValue() {
    final AppTask appTask = ShadowAppTask.newInstance();
    final RecentTaskInfo recentTaskInfo = new RecentTaskInfo();
    recentTaskInfo.description = "com.google.test";
    shadowOf(appTask).setTaskInfo(recentTaskInfo);
    assertThat(appTask.getTaskInfo()).isSameInstanceAs(recentTaskInfo);
}
Also used : AppTask(android.app.ActivityManager.AppTask) RecentTaskInfo(android.app.ActivityManager.RecentTaskInfo) Test(org.junit.Test)

Aggregations

AppTask (android.app.ActivityManager.AppTask)22 ActivityManager (android.app.ActivityManager)11 Intent (android.content.Intent)7 Test (org.junit.Test)6 Uri (android.net.Uri)5 Nullable (android.support.annotation.Nullable)5 TargetApi (android.annotation.TargetApi)3 RecentTaskInfo (android.app.ActivityManager.RecentTaskInfo)2 Context (android.content.Context)2 Activity (android.app.Activity)1 PackageManager (android.content.pm.PackageManager)1 HashSet (java.util.HashSet)1 Config (org.robolectric.annotation.Config)1