[英]Activity's onStop() not called when starting another full screen Activity
[英]WebView media content stops when the screen is locked ( activity's onStop is called)
我有一個可以在MainActivity的WebView
內播放視頻的應用程序。 我遇到的問題是,每當我鎖定屏幕時,視頻就會暫停(調用Activity的onStop
時,即WebView
的視頻暫停時)。
但是,此行為僅發生在Apis> = Lollipop(5.0)上 。
我到處搜索解決方案,但找不到任何東西。 我只希望即使用戶在LockScreen上也能繼續播放視頻。
如果由於onStop而使WebView
暫停,則可以從WebView重寫onWindowVisibilityChanged:
public class MyWebView extends WebView {
public MyWebView(Context context) {
super(context);
}
public MyWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyWebView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onWindowVisibilityChanged(int visibility) {
if (visibility != View.GONE) super.onWindowVisibilityChanged(visibility);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.