I have this problem with Picture in Picture mode that i want to close the PIP (Picture in Picture) when the activity is opened again from somewhere other than the PIP itself. Not from the close button.
I want the same scenario that youtube has i.e. when user clicks the PIP (Picture in Picture) it opens the same activity but when user selects another video form the list it ends the previous PIP (Picture in Picture) and opens a new activity. In my case when i open a new video it resumes the video i was previously playing.