Fix a bug in TaskStackBuilder where task stack PendingIntents would

not clear tasks properly.

Change-Id: I5a7918fa5e400c160409a45d3e00b32f6f4809aa
This commit is contained in:
Adam Powell
2012-04-05 17:54:10 -07:00
parent 818e7e9c83
commit 8ab700cbba

View File

@@ -206,7 +206,15 @@ public class TaskStackBuilder implements Iterable<Intent> {
* @return The obtained PendingIntent
*/
public PendingIntent getPendingIntent(int requestCode, int flags) {
if (mIntents.isEmpty()) {
throw new IllegalStateException(
"No intents added to TaskStackBuilder; cannot getPendingIntent");
}
Intent[] intents = mIntents.toArray(new Intent[mIntents.size()]);
intents[0].addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK |
Intent.FLAG_ACTIVITY_TASK_ON_HOME);
return PendingIntent.getActivities(mSourceContext, requestCode, intents, flags);
}
}