onActivityResult not called if Activity went into PictureInPicture mode

199 Views Asked by At

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!

1

There are 1 best solutions below

2
Deˣ On

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.