Android Intent Flags Reference

All Android Intent flags (FLAG_ACTIVITY_*, FLAG_RECEIVER_*) with behavior.

Searchable Android Intent flag reference with hex constant value, applicable component type and behaviour notes, plus a combined-int calculator that OR's selected flags. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

How do I combine multiple Intent flags?

Bitwise-OR them: intent.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK). Each flag is a distinct bit, so OR-ing produces an int carrying all of them. The calculator on this page does the OR for you.

Android Intent flags, decoded

Intent flags fine-tune how Android launches activities, delivers broadcasts and grants temporary access to content URIs. They are bit constants on android.content.Intent, combined with bitwise-OR and passed to setFlags or addFlags. This reference lists the common FLAG_ACTIVITY_*, FLAG_RECEIVER_* and FLAG_GRANT_* flags with their real hex values, the component type each applies to and what behaviour they change — plus a calculator that OR’s your selection into a single int.

How it works

Each flag occupies one bit of a 32-bit int. To apply several, OR them together:

Intent i = new Intent(this, DetailActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(i);

Activity flags control the back stack and task affinity, receiver flags control broadcast delivery and ordering, and grant flags hand a receiver short-lived read or write access to the URIs in the Intent’s data or ClipData. Because the activity and receiver flag sets are read in different contexts, a handful share the same bit value — so only combine flags meant for the same component type.

The flags you use most often

FLAG_ACTIVITY_NEW_TASK (0x10000000)

Mandatory when starting an activity from a context that is not itself an activity — a Service, a BroadcastReceiver, or the Application context. Without it, Android throws a android.util.AndroidRuntimeException because there is no existing task to add the new activity to. Often paired with CLEAR_TASK when you want to replace the entire back stack.

FLAG_ACTIVITY_CLEAR_TOP (0x04000000)

If the target activity is already somewhere in the current task’s back stack, Android destroys everything above it and delivers the Intent to that existing instance via onNewIntent(). Without this flag, a new duplicate instance would be pushed on top. Pair with SINGLE_TOP to also avoid creating a duplicate if the target is already at the very top.

FLAG_ACTIVITY_SINGLE_TOP (0x20000000)

If an instance of the target activity is already at the top of the current task, the Intent is delivered to that instance via onNewIntent() rather than creating a new one. Does nothing if the activity is anywhere other than the top.

FLAG_ACTIVITY_CLEAR_TASK (0x00008000)

Clears the entire back stack before starting the target activity. Requires NEW_TASK. Useful for logout flows or re-entry points where you want to ensure no previous activity state survives.

FLAG_ACTIVITY_NO_HISTORY (0x40000000)

The activity is not added to the history stack and will finish as soon as the user leaves it. Common for transient screens like splash screens, one-time interstitials, or auth redirects that should not appear when the user presses Back.

FLAG_GRANT_READ_URI_PERMISSION / FLAG_GRANT_WRITE_URI_PERMISSION

These grant temporary access to a content URI to the receiving component, scoped to the duration of that task. Required when sharing files via FileProvider — without the grant flag, the receiving app cannot read the URI even if you pass it in the Intent data.

Common flag combinations

GoalFlags
Launch from a ServiceNEW_TASK
Bring existing screen forwardCLEAR_TOP + SINGLE_TOP
Full restart from loginNEW_TASK + CLEAR_TASK
One-shot screen (no back stack entry)NO_HISTORY
Share a file safelyGRANT_READ_URI_PERMISSION

Tips and notes

  • Grant flags are temporary and automatically revoked when the receiving task finishes.
  • Watch for the shared-bit flags (e.g. 0x40000000) — FLAG_ACTIVITY_NO_HISTORY and FLAG_RECEIVER_REGISTERED_ONLY share the same value but are read in different contexts. Never mix component types in one int.
  • Use addFlags() to add to existing flags rather than replacing them; setFlags() clears the current set first.