How to add a dynamically resolved activity name to the back stack (without using PARENT_ACTIVITY)?

Posted by user3214249 on Stack Overflow See other posts from Stack Overflow or by user3214249
Published on 2014-08-18T21:23:34Z Indexed on 2014/08/18 22:20 UTC
Read the original article Hit count: 174

The goal is

1) Start activity A from AppWidgetProvider or any other background task (it is simple).

2) From activity A go to activity B after clicking Back button.

The problem is that I can't set PARENT_ACTIVITY in AndroidManifest.xml, because the activity B class name gets determined at run time. So in one case I need to go to activity B, in other case it is another activity. Seems like I can't use TaskStackBuilder without PARENT_ACTIVITY.

I could handle this in the finish() method of activity A, but it should be a simpler way to add activity B to the "back stack" when I run startActivity(intent). Any ideas?

© Stack Overflow or respective owner

Related posts about android

Related posts about android-intent