Android WebView not stopping after user presses back

后端 未结 6 1697
傲寒
傲寒 2021-01-31 03:18

I am playing a YouTube video inside a WebView. I am able to play it, but when the person leaves the screen, I am not able to stop the audio from playing.

I tried various

6条回答
  •  北海茫月
    2021-01-31 03:32

    Taken from https://stackoverflow.com/a/17690221/3032209:

    You should call through to the WebView's onPause() and onResume() from your Activity's onPause() and onResume(), respectively.

    Pauses any extra processing associated with this WebView and its associated DOM, plugins, JavaScript etc. For example, if this WebView is taken offscreen, this could be called to reduce unnecessary CPU or network traffic. When this WebView is again "active", call onResume().

提交回复
热议问题