1

When i put my app in multi window mode(Image1) and then press HOME button there, the half screen slides up so that only the status bar of that Activity is visible now(Image2). When the Activity transitions from the first to second image, there is no Activity lifecycle callbacks received like onStop or onResume. I have a video playing on the Activity and i would like to pause the video when my Activity goes to the second phase because the video is not visible now.

1.How can i achieve that?

2.Also a View is visible on the Activity in the first image and that View is not visible in the second image(because the Activity has slided up), using view.getGlobalVisibleRect on that View always returns TRUE in the second case also. How can i determine that the View has been hidden in the second case?

Image1 Image2

Diffy
  • 2,339
  • 3
  • 25
  • 47
  • The official docs say that onStop() should be called , did you debug it? https://developer.android.com/guide/topics/ui/multi-window.html#lifecycle – Hristo Stoyanov Jan 05 '17 at 15:06
  • @HristoStoyanov: Really? Do you have a link for this? It doesn't work, [when I last tried it](https://commonsware.com/blog/2016/09/28/split-screen-not-all-homes-are-created-equal.html), [a Googler says that there is no callback](http://stackoverflow.com/a/39738050/115145), and so [I filed an issue to try to get a callback added for this](https://code.google.com/p/android/issues/detail?id=223943). Now, that was all with 7.0, and so it is possible that 7.1 changed things. – CommonsWare Jan 05 '17 at 15:07
  • @HristoStoyanov Its not written anywhere in the doc that you pointed that `onStop()` has to be called. – Diffy Jan 05 '17 at 15:11
  • 1
    > Note: In multi-window mode, an app can be in the paused state and still be visible to the user. An app might need to continue its activities even while paused. For example, a video-playing app that is in paused mode but is visible should continue showing its video. For this reason, we recommend that activities that play video not pause the video in their onPause() handlers. Instead, they should pause video in onStop(), and resume playback in onStart(). – Hristo Stoyanov Jan 05 '17 at 15:17
  • 1
    @HristoStoyanov: That does not address the scenario being described here. With ordinary navigation, `onStop()` will be called. In this particular "transient HOME" scenario, it is not, and that is the crux of the issue. – CommonsWare Jan 05 '17 at 18:45

0 Answers0