to top
Android APIs
public class

ContextCompat

extends Object
java.lang.Object
   ↳ android.support.v4.content.ContextCompat
Known Direct Subclasses

Class Overview

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

Summary

Public Constructors
ContextCompat()
Public Methods
static boolean startActivities(Context context, Intent[] intents)
Start a set of activities as a synthesized task stack, if able.
static boolean startActivities(Context context, Intent[] intents, Bundle options)
Start a set of activities as a synthesized task stack, if able.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ContextCompat ()

Public Methods

public static boolean startActivities (Context context, Intent[] intents)

Start a set of activities as a synthesized task stack, if able.

In API level 11 (Android 3.0/Honeycomb) the recommended conventions for app navigation using the back key changed. The back key's behavior is local to the current task and does not capture navigation across different tasks. Navigating across tasks and easily reaching the previous task is accomplished through the "recents" UI, accessible through the software-provided Recents key on the navigation or system bar. On devices with the older hardware button configuration the recents UI can be accessed with a long press on the Home key.

When crossing from one task stack to another post-Android 3.0, the application should synthesize a back stack/history for the new task so that the user may navigate out of the new task and back to the Launcher by repeated presses of the back key. Back key presses should not navigate across task stacks.

startActivities provides a mechanism for constructing a synthetic task stack of multiple activities. If the underlying API is not available on the system this method will return false.

Parameters
context Start activities using this activity as the starting context
intents Array of intents defining the activities that will be started. The element length-1 will correspond to the top activity on the resulting task stack.
Returns
  • true if the underlying API was available and the call was successful, false otherwise

public static boolean startActivities (Context context, Intent[] intents, Bundle options)

Start a set of activities as a synthesized task stack, if able.

In API level 11 (Android 3.0/Honeycomb) the recommended conventions for app navigation using the back key changed. The back key's behavior is local to the current task and does not capture navigation across different tasks. Navigating across tasks and easily reaching the previous task is accomplished through the "recents" UI, accessible through the software-provided Recents key on the navigation or system bar. On devices with the older hardware button configuration the recents UI can be accessed with a long press on the Home key.

When crossing from one task stack to another post-Android 3.0, the application should synthesize a back stack/history for the new task so that the user may navigate out of the new task and back to the Launcher by repeated presses of the back key. Back key presses should not navigate across task stacks.

startActivities provides a mechanism for constructing a synthetic task stack of multiple activities. If the underlying API is not available on the system this method will return false.

Parameters
context Start activities using this activity as the starting context
intents Array of intents defining the activities that will be started. The element length-1 will correspond to the top activity on the resulting task stack.
options Additional options for how the Activity should be started. See {@link android.content.Context#startActivity(Intent, Bundle)
Returns
  • true if the underlying API was available and the call was successful, false otherwise