1

Activities

  • Activity A: content list
  • Activity B: player

Flow

Activity A ==> Activity B

  1. Activity A launches Activity B using startActivityForResult
  2. Activity B might go into Picture-in-Picture mode
  3. Activity B calls setResult and then finish
  4. onActivityResult from Activity A is called

Issue

When Activity B goes into Picture-in-Picture, onActivityResult isn't called.

I know that Activity B detaches from Activity A's task stack when it goes into Picture-in-Picture, but I would expect the startActivityForResult to behave as expected. Is this a bug or is it expected ?

Any workaround would be appreciated. Also, my last resort is to re-do it all and use internal broadcasting to communicate both Activities. Feel free to comment on that as well.

Thanks!

Community
  • 1
  • 1
JonZarate
  • 841
  • 6
  • 28

1 Answers1

1

I am not sure as I understand Activity in PIP mode is considered Pause. But there is some development in the multi-resume feature. To opt-in to this behavior in Android P, add the following meta-data in your app manifest:

<meta-data android:name="android.allow_multiple_resumed_activities" android:value="true" />

You can read about this here.

Deˣ
  • 4,191
  • 15
  • 24
  • Indeed, the Activity stays in a `paused` state, which might be blocking the call to `onActivityResult`. However, I need a solution for regular devices, not folded ones and also for pre Android P. Thanks tho, +1! – JonZarate Jun 12 '19 at 15:58
  • As you said, for now, the best way would be to use broadcast until the Google team handles this. :-) – Deˣ Jun 12 '19 at 16:08