Open TechToArt opened 8 months ago
Ran into the same problem today.
When I tried to set custom action to closeAction
, nothing happened.
Even the document of setCloseAction
is not so clear when saying :
custom action must close the activity quickly using {@link Activity#finish()}
/**
* Sets a close action that should be invoked before the default close PiP action. The
* custom action must close the activity quickly using {@link Activity#finish()}.
* Otherwise, the system will forcibly close the PiP as if no custom close action was
* provided.
*
* If the action matches one set via {@link PictureInPictureParams.Builder#setActions(List)}
* it may be shown in place of that custom action in the menu.
*
* @param action to replace the system close action
* @return this builder instance.
* @see RemoteAction
*/
At then end, I ended up with a solution to implement my logic in onStop
function of Activity
.
override fun onStop() {
if (isInPictureInPictureMode) {
// logic goes here.
}
super.onStop()
}
I tried to use "PictureInPictureParams.Builder.setCloseAction(RemoteAction)" to finish Activity, but is not work. what should i do?