Skip to content

Most visited

Recently visited

navigation

IntentCompat

public final class IntentCompat
extends Object

java.lang.Object
   ↳ android.support.v4.content.IntentCompat


Helper for accessing features in Intent introduced after API level 4 in a backwards compatible fashion.

Summary

Constants

String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

This constant was deprecated in API level 26.0.0-alpha1. Use ACTION_EXTERNAL_APPLICATIONS_AVAILABLE directly.

String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE

This constant was deprecated in API level 26.0.0-alpha1. Use ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE directly.

String CATEGORY_LEANBACK_LAUNCHER

Indicates an activity optimized for Leanback mode, and that should be displayed in the Leanback launcher.

String EXTRA_CHANGED_PACKAGE_LIST

This constant was deprecated in API level 26.0.0-alpha1. Use EXTRA_CHANGED_PACKAGE_LIST directly.

String EXTRA_CHANGED_UID_LIST

This constant was deprecated in API level 26.0.0-alpha1. Use EXTRA_CHANGED_UID_LIST directly.

String EXTRA_HTML_TEXT

A constant String that is associated with the Intent, used with ACTION_SEND to supply an alternative to EXTRA_TEXT as HTML formatted text.

String EXTRA_START_PLAYBACK

Used as a boolean extra field in ACTION_VIEW intents to indicate that content should immediately be played without any intermediate screens that require additional user input, e.g.

int FLAG_ACTIVITY_CLEAR_TASK

This constant was deprecated in API level 26.0.0-alpha1. Use FLAG_ACTIVITY_CLEAR_TASK directly.

int FLAG_ACTIVITY_TASK_ON_HOME

This constant was deprecated in API level 26.0.0-alpha1. Use FLAG_ACTIVITY_TASK_ON_HOME directly.

Public methods

static Intent makeMainActivity(ComponentName mainActivity)

This method was deprecated in API level 26.0.0-alpha1. Use makeMainActivity(ComponentName) directly.

static Intent makeMainSelectorActivity(String selectorAction, String selectorCategory)

Make an Intent for the main activity of an application, without specifying a specific activity to run but giving a selector to find the activity.

static Intent makeRestartActivityTask(ComponentName mainActivity)

This method was deprecated in API level 26.0.0-alpha1. Use makeRestartActivityTask(ComponentName) directly.

Inherited methods

From class java.lang.Object

Constants

ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

added in version 22.0.0
String ACTION_EXTERNAL_APPLICATIONS_AVAILABLE

This constant was deprecated in API level 26.0.0-alpha1.
Use ACTION_EXTERNAL_APPLICATIONS_AVAILABLE directly.

Broadcast Action: Resources for a set of packages (which were previously unavailable) are currently available since the media on which they exist is available. The extra data EXTRA_CHANGED_PACKAGE_LIST contains a list of packages whose availability changed. The extra data EXTRA_CHANGED_UID_LIST contains a list of uids of packages whose availability changed. Note that the packages in this list do not receive this broadcast. The specified set of packages are now available on the system.

Includes the following extras:

  • EXTRA_CHANGED_PACKAGE_LIST is the set of packages whose resources(were previously unavailable) are currently available. EXTRA_CHANGED_UID_LIST is the set of uids of the packages whose resources(were previously unavailable) are currently available.

This is a protected intent that can only be sent by the system.

Constant Value: "android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE"

ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE

added in version 22.0.0
String ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE

This constant was deprecated in API level 26.0.0-alpha1.
Use ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE directly.

Broadcast Action: Resources for a set of packages are currently unavailable since the media on which they exist is unavailable. The extra data EXTRA_CHANGED_PACKAGE_LIST contains a list of packages whose availability changed. The extra data EXTRA_CHANGED_UID_LIST contains a list of uids of packages whose availability changed. The specified set of packages can no longer be launched and are practically unavailable on the system.

Inclues the following extras:

This is a protected intent that can only be sent by the system.

Constant Value: "android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE"

CATEGORY_LEANBACK_LAUNCHER

added in version 23.4.0
String CATEGORY_LEANBACK_LAUNCHER

Indicates an activity optimized for Leanback mode, and that should be displayed in the Leanback launcher.

Constant Value: "android.intent.category.LEANBACK_LAUNCHER"

EXTRA_CHANGED_PACKAGE_LIST

added in version 22.0.0
String EXTRA_CHANGED_PACKAGE_LIST

This constant was deprecated in API level 26.0.0-alpha1.
Use EXTRA_CHANGED_PACKAGE_LIST directly.

This field is part of ACTION_EXTERNAL_APPLICATIONS_AVAILABLE, ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE and contains a string array of all of the components that have changed.

Constant Value: "android.intent.extra.changed_package_list"

EXTRA_CHANGED_UID_LIST

added in version 22.0.0
String EXTRA_CHANGED_UID_LIST

This constant was deprecated in API level 26.0.0-alpha1.
Use EXTRA_CHANGED_UID_LIST directly.

This field is part of ACTION_EXTERNAL_APPLICATIONS_AVAILABLE, ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE and contains an integer array of uids of all of the components that have changed.

Constant Value: "android.intent.extra.changed_uid_list"

EXTRA_HTML_TEXT

added in version 22.0.0
String EXTRA_HTML_TEXT

A constant String that is associated with the Intent, used with ACTION_SEND to supply an alternative to EXTRA_TEXT as HTML formatted text. Note that you must also supply EXTRA_TEXT.

Constant Value: "android.intent.extra.HTML_TEXT"

EXTRA_START_PLAYBACK

added in version 25.4.0
String EXTRA_START_PLAYBACK

Used as a boolean extra field in ACTION_VIEW intents to indicate that content should immediately be played without any intermediate screens that require additional user input, e.g. a profile selection screen or a details page.

Constant Value: "android.intent.extra.START_PLAYBACK"

FLAG_ACTIVITY_CLEAR_TASK

added in version 22.0.0
int FLAG_ACTIVITY_CLEAR_TASK

This constant was deprecated in API level 26.0.0-alpha1.
Use FLAG_ACTIVITY_CLEAR_TASK directly.

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.

This flag will only be obeyed on devices supporting API 11 or higher.

Constant Value: 32768 (0x00008000)

FLAG_ACTIVITY_TASK_ON_HOME

added in version 22.0.0
int FLAG_ACTIVITY_TASK_ON_HOME

This constant was deprecated in API level 26.0.0-alpha1.
Use FLAG_ACTIVITY_TASK_ON_HOME directly.

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.

Constant Value: 16384 (0x00004000)

Public methods

makeMainActivity

added in version 22.0.0
Intent makeMainActivity (ComponentName mainActivity)

This method was deprecated in API level 26.0.0-alpha1.
Use makeMainActivity(ComponentName) directly.

Create an intent to launch the main (root) activity of a task. This is the Intent that is started when the application's is launched from Home. For anything else that wants to launch an application in the same way, it is important that they use an Intent structured the same way, and can use this function to ensure this is the case.

The returned Intent has the given Activity component as its explicit component, ACTION_MAIN as its action, and includes the category CATEGORY_LAUNCHER. This does not have FLAG_ACTIVITY_NEW_TASK set, though typically you will want to do that through addFlags(int) on the returned Intent.

Parameters
mainActivity ComponentName: The main activity component that this Intent will launch.

Returns
Intent Returns a newly created Intent that can be used to launch the activity as a main application entry.

See also:

makeMainSelectorActivity

added in version 22.0.0
Intent makeMainSelectorActivity (String selectorAction, 
                String selectorCategory)

Make an Intent for the main activity of an application, without specifying a specific activity to run but giving a selector to find the activity. This results in a final Intent that is structured the same as when the application is launched from Home. For anything else that wants to launch an application in the same way, it is important that they use an Intent structured the same way, and can use this function to ensure this is the case.

The returned Intent has ACTION_MAIN as its action, and includes the category CATEGORY_LAUNCHER. This does not have FLAG_ACTIVITY_NEW_TASK set, though typically you will want to do that through addFlags(int) on the returned Intent.

Parameters
selectorAction String: The action name of the Intent's selector.

selectorCategory String: The name of a category to add to the Intent's selector.

Returns
Intent Returns a newly created Intent that can be used to launch the activity as a main application entry.

makeRestartActivityTask

added in version 22.0.0
Intent makeRestartActivityTask (ComponentName mainActivity)

This method was deprecated in API level 26.0.0-alpha1.
Use makeRestartActivityTask(ComponentName) directly.

Make an Intent that can be used to re-launch an application's task in its base state. This is like makeMainActivity(ComponentName), but also sets the flags FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK.

Parameters
mainActivity ComponentName: The activity component that is the root of the task; this is the activity that has been published in the application's manifest as the main launcher icon.

Returns
Intent Returns a newly created Intent that can be used to relaunch the activity's task in its root state.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.