I am trying to make our video app to support Android N multiwindow mode. I have discovered that activity lifecycle becomes confused in multiwindow mode. The phenomenon is when our app layouts on the top screen with the whole screen in portrait, then I click the Home button, the upper app onPause()
called but onStop()
not called.
According to the google guideline https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle, video app should pause video playback in onStop()
callback rather than onPause()
callback.
In this situation, home button is pressed, the activity go background and become not visible to user, our app should pause video playback but we cannot get onStop()
callback. Meanwhile, the activity do not fire onMultiWindowChanged()
callback, this means the activity is still in multiwindow mode though it is in background. The isInMultiWindowMode()
will return true
in this case.
The same issue will occur when the app is in the left screen with the whole screen in landscape.
I have searched for this question and find someone has alreay post issues to google but not handled in the Android Nougat release.
So, when is the right time to pause our video playback in such situation? If we pause the video in the onPause()
callback, but the activity may be visible to user in multiwindow mode. If we not do, we cannot get the onStop()
callback in this case.
Are there some proper workaround for such cases?