Stay organized with collections Save and categorize content based on your preferences.

public static class ActivityManager.AppTask
extends Object



The AppTask allows you to manage your own application's tasks. See ActivityManager.getAppTasks()

Summary

Public methods

void finishAndRemoveTask()

Finishes all activities in this task and removes it from the recent tasks list.

ActivityManager.RecentTaskInfo getTaskInfo()

Get the RecentTaskInfo associated with this task.

void moveToFront()

Bring this task to the foreground.

void setExcludeFromRecents(boolean exclude)

Modify the Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag in the root Intent of this AppTask.

void startActivity(Context context, Intent intent, Bundle options)

Start an activity in this task.

Inherited methods

From class java.lang.Object

Object clone()

Creates and returns a copy of this object.

boolean equals(Object obj)

Indicates whether some other object is "equal to" this one.

void finalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

final Class<?> getClass()

Returns the runtime class of this Object.

int hashCode()

Returns a hash code value for the object.

final void notify()

Wakes up a single thread that is waiting on this object's monitor.

final void notifyAll()

Wakes up all threads that are waiting on this object's monitor.

String toString()

Returns a string representation of the object.

final void wait(long timeoutMillis, int nanos)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait(long timeoutMillis)

Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

final void wait()

Causes the current thread to wait until it is awakened, typically by being notified or interrupted.

Public methods

finishAndRemoveTask

public void finishAndRemoveTask ()

Finishes all activities in this task and removes it from the recent tasks list.

getTaskInfo

public ActivityManager.RecentTaskInfo getTaskInfo ()

Get the RecentTaskInfo associated with this task.

Returns
ActivityManager.RecentTaskInfo The RecentTaskInfo for this task, or null if the task no longer exists.

moveToFront

public void moveToFront ()

Bring this task to the foreground. If it contains activities, they will be brought to the foreground with it and their instances re-created if needed. If it doesn't contain activities, the root activity of the task will be re-launched.

setExcludeFromRecents

public void setExcludeFromRecents (boolean exclude)

Modify the Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag in the root Intent of this AppTask.

Parameters
exclude boolean: If true, Intent#FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS will be set; otherwise, it will be cleared.

startActivity

public void startActivity (Context context, 
                Intent intent, 
                Bundle options)

Start an activity in this task. Brings the task to the foreground. If this task is not currently active (that is, its id < 0), then a new activity for the given Intent will be launched as the root of the task and the task brought to the foreground. Otherwise, if this task is currently active and the Intent does not specify an activity to launch in a new task, then a new activity for the given Intent will be launched on top of the task and the task brought to the foreground. If this task is currently active and the Intent specifies Intent#FLAG_ACTIVITY_NEW_TASK or would otherwise be launched in to a new task, then the activity not launched but this task be brought to the foreground and a new intent delivered to the top activity if appropriate.

In other words, you generally want to use an Intent here that does not specify Intent#FLAG_ACTIVITY_NEW_TASK or Intent#FLAG_ACTIVITY_NEW_DOCUMENT, and let the system do the right thing.

Parameters
context Context
intent Intent: The Intent describing the new activity to be launched on the task.
options Bundle: Optional launch options.

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2023-02-08 UTC.