ActivityFlags Enum

Definition

Enumerates values returned by several types and taken as a parameter of several types.

This enumeration supports a bitwise combination of its member values.

[System.Flags]
public enum ActivityFlags
[<System.Flags>]
type ActivityFlags = 
Inheritance
ActivityFlags
Attributes

Fields

Name Value Description
GrantReadUriPermission 1

If set, the recipient of this Intent will be granted permission to perform read operations on the Uri in the Intent's data and any URIs specified in its ClipData.

GrantWriteUriPermission 2

If set, the recipient of this Intent will be granted permission to perform write operations on the Uri in the Intent's data and any URIs specified in its ClipData.

FromBackground 4

Can be set by the caller to indicate that this Intent is coming from a background operation, not from direct user interaction.

DebugLogResolution 8

A flag you can enable for debugging: when set, log messages will be printed during the resolution of this intent to show you what has been found to create the final resolved list.

ExcludeStoppedPackages 16

If set, this intent will not match any components in packages that are currently stopped.

IncludeStoppedPackages 32

If set, this intent will always match any components in packages that are currently stopped.

GrantPersistableUriPermission 64

When combined with FLAG_GRANT_READ_URI_PERMISSION and/or FLAG_GRANT_WRITE_URI_PERMISSION , the URI permission grant can be persisted across device reboots until explicitly revoked with Context.revokeUriPermission(Uri,int) . This flag only offers the grant for possible persisting; the receiving application must call ContentResolver.takePersistableUriPermission(Uri,int) to actually persist.

GrantPrefixUriPermission 128

When combined with FLAG_GRANT_READ_URI_PERMISSION and/or FLAG_GRANT_WRITE_URI_PERMISSION , the URI permission grant applies to any URI that is a prefix match against the original granted URI. (Without this flag, the URI must match exactly for access to be granted.) Another URI is considered a prefix match only when scheme, authority, and all path segments defined by the prefix are an exact match.

DirectBootAuto 256

Flag used to automatically match intents based on their Direct Boot awareness and the current user state. Since the default behavior is to automatically apply the current user state, this is effectively a sentinel value that doesn't change the output of any queries based on its presence or absence. Instead, this value can be useful in conjunction with StrictMode.VmPolicy.Builder.detectImplicitDirectBoot() to detect when a caller is relying on implicit automatic matching, instead of confirming the explicit behavior they want. Constant Value: 256 (0x00000100)

RequireDefault 512

If set in an intent passed to Context.startActivity() , this flag will only launch the intent if it resolves to a single result. If no such result exists or if the system chooser would otherwise be displayed, an ActivityNotFoundException will be thrown.

RequireNonBrowser 1024

If set in an intent passed to Context.startActivity() , this flag will only launch the intent if it resolves to a result that is not a browser. If no such result exists, an ActivityNotFoundException will be thrown.

MatchExternal 2048

If set in an Intent passed to Context.startActivity() , this flag will attempt to launch an instant app if no full app on the device can already handle the intent. When attempting to resolve instant apps externally, the following Intent properties are supported: Intent.setAction(String) Intent.addCategory(String) Intent.setData(Uri) Intent.setType(String) Intent.setPackage(String) Intent.addFlags(int) In the case that no instant app can be found, the installer will be launched to notify the user that the intent could not be resolved. On devices that do not support instant apps, the flag will be ignored. Constant Value: 2048 (0x00000800)

LaunchAdjacent 4096

This flag is only used for split-screen multi-window mode. The new activity will be displayed adjacent to the one launching it if possible. This can only be used in conjunction with FLAG_ACTIVITY_NEW_TASK . Also, setting FLAG_ACTIVITY_MULTIPLE_TASK is required if you want a new instance of an existing activity to be created.

RetainInRecents 8192

By default a document created by FLAG_ACTIVITY_NEW_DOCUMENT will have its entry in recent tasks removed when the user closes it (with back or however else it may finish()). If you would like to instead allow the document to be kept in recents so that it can be re-launched, you can use this flag. When set and the task's activity is finished, the recents entry will remain in the interface for the user to re-launch it, like a recents entry for a top-level application. The receiving activity can override this request with R.attr.autoRemoveFromRecents or by explcitly calling Activity.finishAndRemoveTask() .

TaskOnHome 16384

If set in an Intent passed to Context.startActivity() , this flag will cause a newly launching task to be placed on top of the current home activity task (if there is one). That is, pressing back from the task will always return the user to home even if that was not the last activity they saw. This can only be used in conjunction with FLAG_ACTIVITY_NEW_TASK .

ClearTask 32768

If set in an Intent passed to Context.startActivity() , this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started. That is, the activity becomes the new root of an otherwise empty task, and any old activities are finished. This can only be used in conjunction with FLAG_ACTIVITY_NEW_TASK .

NoAnimation 65536

If set in an Intent passed to Context.startActivity() , this flag will prevent the system from applying an activity transition animation to go to the next activity state. This doesn't mean an animation will never run -- if another activity change happens that doesn't specify this flag before the activity started here is displayed, then that transition will be used. This flag can be put to good use when you are going to do a series of activity operations but the animation seen by the user shouldn't be driven by the first activity change but rather a later one.

ReorderToFront 131072

If set in an Intent passed to Context.startActivity() , this flag will cause the launched activity to be brought to the front of its task's history stack if it is already running. For example, consider a task consisting of four activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then B will be brought to the front of the history stack, with this resulting order: A, C, D, B. This flag will be ignored if FLAG_ACTIVITY_CLEAR_TOP is also specified.

NoUserAction 262144

If set, this flag will prevent the normal Activity.onUserLeaveHint() callback from occurring on the current frontmost activity before it is paused as the newly-started activity is brought to the front. Typically, an activity can rely on that callback to indicate that an explicit user action has caused their activity to be moved out of the foreground. The callback marks an appropriate point in the activity's lifecycle for it to dismiss any notifications that it intends to display "until the user has seen them," such as a blinking LED. If an activity is ever started via any non-user-driven events such as phone-call receipt or an alarm handler, this flag should be passed to Context.startActivity , ensuring that the pausing activity does not think the user has acknowledged its notification. Constant Value: 262144 (0x00040000)

ClearWhenTaskReset 524288

This constant was deprecated in API level 21. As of API 21 this performs identically to FLAG_ACTIVITY_NEW_DOCUMENT which should be used instead of this.

NewDocument 524288

This flag is used to open a document into a new task rooted at the activity launched by this Intent. Through the use of this flag, or its equivalent attribute, R.attr.documentLaunchMode multiple instances of the same activity containing different documents will appear in the recent tasks list. The use of the activity attribute form of this, R.attr.documentLaunchMode , is preferred over the Intent flag described here. The attribute form allows the Activity to specify multiple document behavior for all launchers of the Activity whereas using this flag requires each Intent that launches the Activity to specify it. Note that the default semantics of this flag w.r.t. whether the recents entry for it is kept after the activity is finished is different than the use of FLAG_ACTIVITY_NEW_TASK and R.attr.documentLaunchMode -- if this flag is being used to create a new recents entry, then by default that entry will be removed once the activity is finished. You can modify this behavior with FLAG_ACTIVITY_RETAIN_IN_RECENTS . FLAG_ACTIVITY_NEW_DOCUMENT may be used in conjunction with FLAG_ACTIVITY_MULTIPLE_TASK . When used alone it is the equivalent of the Activity manifest specifying R.attr.documentLaunchMode ="intoExisting". When used with FLAG_ACTIVITY_MULTIPLE_TASK it is the equivalent of the Activity manifest specifying R.attr.documentLaunchMode ="always". The flag is ignored even in conjunction with FLAG_ACTIVITY_MULTIPLE_TASK when the Activity manifest specifies R.attr.documentLaunchMode ="never". Refer to R.attr.documentLaunchMode for more information. See also: R.attr.documentLaunchMode FLAG_ACTIVITY_MULTIPLE_TASK Constant Value: 524288 (0x00080000)

LaunchedFromHistory 1048576

This flag is not normally set by application code, but set for you by the system if this activity is being launched from history (longpress home key).

ReceiverVisibleToInstantApps 2097152

If set, the broadcast will be visible to receivers in Instant Apps. By default Instant Apps will not receive broadcasts. This flag has no effect when used by an Instant App.

ResetTaskIfNeeded 2097152

If set, and this activity is either being started in a new task or bringing to the top an existing task, then it will be launched as the front door of the task.

BroughtToFront 4194304

This flag is not normally set by application code, but set for you by the system as described in the launchMode documentation for the singleTask mode.

ExcludeFromRecents 8388608

If set, the new activity is not kept in the list of recently launched activities.

PreviousIsTop 16777216

If set and this intent is being used to launch a new activity from an existing one, the current activity will not be counted as the top activity for deciding whether the new intent should be delivered to the top instead of starting a new one. The previous activity will be used as the top, with the assumption being that the current activity will finish itself immediately.

ForwardResult 33554432

If set and this intent is being used to launch a new activity from an existing one, then the reply target of the existing activity will be transfered to the new activity.

ClearTop 67108864

If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent. For example, consider a task consisting of the activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then C and D will be finished and B receive the given Intent, resulting in the stack now being: A, B. The currently running instance of activity B in the above example will either receive the new intent you are starting here in its onNewIntent() method, or be itself finished and restarted with the new intent. If it has declared its launch mode to be "multiple" (the default) and you have not set FLAG_ACTIVITY_SINGLE_TOP in the same intent, then it will be finished and re-created; for all other launch modes or if FLAG_ACTIVITY_SINGLE_TOP is set then this Intent will be delivered to the current instance's onNewIntent(). This launch mode can also be used to good effect in conjunction with FLAG_ACTIVITY_NEW_TASK : if used to start the root activity of a task, it will bring any currently running instance of that task to the foreground, and then clear it to its root state. This is especially useful, for example, when launching an activity from the notification manager. See Tasks and Back Stack for more information about tasks. Constant Value: 67108864 (0x04000000)

MultipleTask 134217728

Do not use this flag unless you are implementing your own top-level application launcher. NewTask always

Because the default system does not include graphical task management, you should not use this flag unless you provide some way for a user to return back to the tasks you have launched.

NewTask

See Tasks and Back Stack for more information about tasks.

ReceiverNoAbort 134217728

If this is an ordered broadcast, don't allow receivers to abort the broadcast. They can still propagate results through to later receivers, but they can not prevent later receivers from seeing the broadcast.

NewTask 268435456

If set, this activity will become the start of a new task on this history stack. A task (from the activity that started it to the next task activity) defines an atomic group of activities that the user can move to. Tasks can be moved to the foreground and background; all of the activities inside of a particular task always remain in the same order. See Tasks and Back Stack for more information about tasks. This flag is generally used by activities that want to present a "launcher" style behavior: they give the user a list of separate things that can be done, which otherwise run completely independently of the activity launching them. When using this flag, if a task is already running for the activity you are now starting, then a new activity will not be started; instead, the current task will simply be brought to the front of the screen with the state it was last in. See FLAG_ACTIVITY_MULTIPLE_TASK for a flag to disable this behavior. This flag can not be used when the caller is requesting a result from the activity being launched. Constant Value: 268435456 (0x10000000)

ReceiverForeground 268435456

If set, when sending a broadcast the recipient is allowed to run at foreground priority, with a shorter timeout interval.

ReceiverReplacePending 536870912

If set, when sending a broadcast the new broadcast will replace any existing pending broadcast that matches it. Matching is defined by Intent.filterEquals returning true for the intents of the two broadcasts. When a match is found, the new broadcast (and receivers associated with it) will replace the existing one in the pending broadcast list, remaining at the same position in the list. This flag is most typically used with sticky broadcasts, which only care about delivering the most recent values of the broadcast to their receivers.

SingleTop 536870912

If set, the activity will not be launched if it is already running at the top of the history stack.

NoHistory 1073741824

If set, the new activity is not kept in the history stack.

ReceiverRegisteredOnly 1073741824

If set, when sending a broadcast only registered receivers will be called -- no BroadcastReceiver components will be launched.

Remarks

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to