Methods Summary |
---|
public android.support.v4.app.TaskStackBuilder | addNextIntent(android.content.Intent nextIntent)Add a new Intent to the task stack. The most recently added Intent will invoke
the Activity at the top of the final task stack.
mIntents.add(nextIntent);
return this;
|
public android.support.v4.app.TaskStackBuilder | addNextIntentWithParentStack(android.content.Intent nextIntent)Add a new Intent with the resolved chain of parents for the target activity to
the task stack.
This is equivalent to calling {@link #addParentStack(ComponentName) addParentStack}
with the resolved ComponentName of nextIntent (if it can be resolved), followed by
{@link #addNextIntent(Intent) addNextIntent} with nextIntent.
ComponentName target = nextIntent.getComponent();
if (target == null) {
target = nextIntent.resolveActivity(mSourceContext.getPackageManager());
}
if (target != null) {
addParentStack(target);
}
addNextIntent(nextIntent);
return this;
|
public android.support.v4.app.TaskStackBuilder | addParentStack(android.app.Activity sourceActivity)Add the activity parent chain as specified by manifest <meta-data> elements
to the task stack builder.
Intent parent = null;
if (sourceActivity instanceof SupportParentable) {
parent = ((SupportParentable) sourceActivity).getSupportParentActivityIntent();
}
if (parent == null) {
parent = NavUtils.getParentActivityIntent(sourceActivity);
}
if (parent != null) {
// We have the actual parent intent, build the rest from static metadata
// then add the direct parent intent to the end.
ComponentName target = parent.getComponent();
if (target == null) {
target = parent.resolveActivity(mSourceContext.getPackageManager());
}
addParentStack(target);
addNextIntent(parent);
}
return this;
|
public android.support.v4.app.TaskStackBuilder | addParentStack(java.lang.Class sourceActivityClass)Add the activity parent chain as specified by manifest <meta-data> elements
to the task stack builder.
return addParentStack(new ComponentName(mSourceContext, sourceActivityClass));
|
public android.support.v4.app.TaskStackBuilder | addParentStack(android.content.ComponentName sourceActivityName)Add the activity parent chain as specified by manifest <meta-data> elements
to the task stack builder.
final int insertAt = mIntents.size();
try {
Intent parent = NavUtils.getParentActivityIntent(mSourceContext, sourceActivityName);
while (parent != null) {
mIntents.add(insertAt, parent);
parent = NavUtils.getParentActivityIntent(mSourceContext, parent.getComponent());
}
} catch (NameNotFoundException e) {
Log.e(TAG, "Bad ComponentName while traversing activity parent metadata");
throw new IllegalArgumentException(e);
}
return this;
|
public static android.support.v4.app.TaskStackBuilder | create(android.content.Context context)Return a new TaskStackBuilder for launching a fresh task stack consisting
of a series of activities.
return new TaskStackBuilder(context);
|
public android.content.Intent | editIntentAt(int index)Return the intent at the specified index for modification.
Useful if you need to modify the flags or extras of an intent that was previously added,
for example with {@link #addParentStack(Activity)}.
return mIntents.get(index);
|
public static android.support.v4.app.TaskStackBuilder | from(android.content.Context context)Return a new TaskStackBuilder for launching a fresh task stack consisting
of a series of activities.
return create(context);
|
public android.content.Intent | getIntent(int index)Get the intent at the specified index.
Useful if you need to modify the flags or extras of an intent that was previously added,
for example with {@link #addParentStack(Activity)}.
return editIntentAt(index);
|
public int | getIntentCount()
return mIntents.size();
|
public android.content.Intent[] | getIntents()Return an array containing the intents added to this builder. The intent at the
root of the task stack will appear as the first item in the array and the
intent at the top of the stack will appear as the last item.
Intent[] intents = new Intent[mIntents.size()];
if (intents.length == 0) return intents;
intents[0] = new Intent(mIntents.get(0)).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
for (int i = 1; i < intents.length; i++) {
intents[i] = new Intent(mIntents.get(i));
}
return intents;
|
public android.app.PendingIntent | getPendingIntent(int requestCode, int flags)Obtain a {@link PendingIntent} for launching the task constructed by this builder so far.
return getPendingIntent(requestCode, flags, null);
|
public android.app.PendingIntent | getPendingIntent(int requestCode, int flags, android.os.Bundle options)Obtain a {@link PendingIntent} for launching the task constructed by this builder so far.
if (mIntents.isEmpty()) {
throw new IllegalStateException(
"No intents added to TaskStackBuilder; cannot getPendingIntent");
}
Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
// Appropriate flags will be added by the call below.
return IMPL.getPendingIntent(mSourceContext, intents, requestCode, flags, options);
|
public java.util.Iterator | iterator()
return mIntents.iterator();
|
public void | startActivities()Start the task stack constructed by this builder. The Context used to obtain
this builder must be an Activity.
On devices that do not support API level 11 or higher the topmost activity
will be started as a new task. On devices that do support API level 11 or higher
the new task stack will be created in its entirety.
startActivities(null);
|
public void | startActivities(android.os.Bundle options)Start the task stack constructed by this builder. The Context used to obtain
this builder must be an Activity.
On devices that do not support API level 11 or higher the topmost activity
will be started as a new task. On devices that do support API level 11 or higher
the new task stack will be created in its entirety.
if (mIntents.isEmpty()) {
throw new IllegalStateException(
"No intents added to TaskStackBuilder; cannot startActivities");
}
Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
intents[0] = new Intent(intents[0]).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
IntentCompat.FLAG_ACTIVITY_CLEAR_TASK |
IntentCompat.FLAG_ACTIVITY_TASK_ON_HOME);
if (!ContextCompat.startActivities(mSourceContext, intents, options)) {
Intent topIntent = new Intent(intents[intents.length - 1]);
topIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mSourceContext.startActivity(topIntent);
}
|