Ir al contenido

Más visitados

Visitados recientemente

navigation
added in API level 21

ActivityManager.AppTask

public static class ActivityManager.AppTask
extends Object

java.lang.Object
   ↳ android.app.ActivityManager.AppTask


The AppTask allows you to manage your own application's tasks. See 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 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

Public methods

finishAndRemoveTask

added in API level 21
void finishAndRemoveTask ()

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

getTaskInfo

added in API level 21
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

added in API level 21
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

added in API level 21
void setExcludeFromRecents (boolean exclude)

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

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

startActivity

added in API level 21
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 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 FLAG_ACTIVITY_NEW_TASK or 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.

Utilizamos cookies para registrar tus preferencias de idioma y visualización de este sitio web.

Recibe novedades y consejos para desarrolladores de Android que te ayudarán a alcanzar el éxito en Google Play.

* Campos obligatorios

¡Ya está!

Seguir a Google Developers en WeChat

¿Quieres navegar por el sitio web en ?

Has solicitado que la página aparezca en , pero tu idioma preferido en este sitio web es el .

¿Quieres cambiar tu preferencia de idioma y navegar por este sitio web en ? Si prefieres dejarlo para más tarde, usa el menú de idioma que se encuentra en la parte inferior de cada página web.

Para esta clase se necesita un nivel de API o superior

La documentación está oculta porque el nivel de API que has seleccionado para ella es . Cambia el nivel de API de la documentación en el selector situado encima del menú de navegación de la izquierda.

Para obtener más información sobre cómo especificar el nivel de API que requiere tu aplicación, lee el artículo Supporting Different Platform Versions (Compatibilidad con diferentes versiones de la plataforma).

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)