0

I've got an Android App Widget that when clicked uses a PendingIntent to start an Activity, which the main Application associated with the App Widget also uses. After the user is done with the Activity started from the App Widget, and presses the back button, the user is taken to the Activity on the top of the MAIN application Activity stack. I'd like the back button to take the user back to the Android desktop/home screen.

In short, I'd like separate Activity stacks for my App Widget and Application. Not sure why Android wants to combine these.

This is what I've got now in the App Widget and it's not working. Neither Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK seems to have any impact on the stack.

Intent intent = buildWidgetIntent(context, info);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

PendingIntent pendingIntent = PendingIntent.getActivity(context,
mRequestCode++, intent, PendingIntent.FLAG_UPDATE_CURRENT);

Thanks for any help with this one.

igorepst
  • 1,230
  • 1
  • 12
  • 20
Roger
  • 21
  • 3

1 Answers1

0

I haven't faced this exact situation, but Intent.FLAG_ACTIVITY_NO_HISTORY is what I needed to make my widget-launched Activity always go Back to the Home screen.

Jon Shemitz
  • 1,235
  • 13
  • 29