takharsh
takharsh

Reputation: 2688

How to close PIP picture in picture activity on click of application icon. I have multiple activities in my app?

Please suggest for the issue related to android picture-in-picture mode, if my app has stack like HomeActivity -> DetailsActivity -> PlayerActivity now on clicking device home button PlayerActivity goes to PIP mode. now if I click on application icon again it starts from HomeActivity as it is Launcher activity defined in manifest. I want it to start from PlayerActivity which is in PIP mode and dismiss the PIP mode. Same experience like google maps navigation. I am aware it is achievable using single activity application but my app has multiple activities.

OR

I want to close the PIP activity(PlayerActivity) when app icon is launched. As PIP activity is running in separate task How to close all the other tasks running for the application?

Upvotes: 1

Views: 4126

Answers (2)

Mostafa Hadian
Mostafa Hadian

Reputation: 1

On some of the Android 8 devices, the activityManager.appTasks did not contain the player activity (in pip mode). Using the Local broadcast was very helpful.

Upvotes: 0

takharsh
takharsh

Reputation: 2688

To close PIP window while launching app using local broadcast, Implement local broadcast and send the broadcast from your launcher activity to PIP activity to close itself.

It is cleaner approach than finding the activity from all the running tasks and finish the task.

Upvotes: 1

Related Questions