I have the following requirement:
Action A ---> Activity B ---> Open Gallery Application
Traditionally, I run nested actions using TaskStackBuilder . So I would do something like this:
TaskStackBuilder tsb = TaskStackBuilder.create(this); Intent activityIntentA = new Intent(this, ActivityA.class) // ... tsb.addNextIntent(activityIntentA); Intent activityIntentB = new Intent(this, ActivityB.class) // ... tsb.addNextIntent(activityIntentB); Intent galleryIntent = new Intent(Intent.ACTION_PICK); galleryIntent.setType("image/*"); tsb.addNextIntent(galleryIntent); // this.startActivities(new Intent[] {activityIntentA, activityIntentB, galleryIntent}); tsb.startActivities();
(The question is whether there is a difference between using the task stack constructor or calling startActivities ()).
The problem with this approach is that when galleryIntent is closed, it does not call onActivityResult , but calls the OnCreate ActivityB method, which means that I lose information coming from the gallery application, which is transmitted through the "data" of the intent parameters to my activity onActivityResult call B.
An alternative solution would be to manually initiate calls, so call the first call to Activity B, then with the flag / parameter / argument, run galleryIntent, and then execute a regular thread using onActivityResult .
Is there a better approach to solving this requirement?
source share