0
我有一個加載報紙網站的應用程序。用戶可以訪問新聞並觀看視頻(如果有的話)。如果視頻在按下後退按鈕時處於全屏狀態,則應用會轉到新報紙主頁而不是新聞。當html5視頻全屏時,更改webview的返回方式
活動代碼:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the Back button and if there's history
if (QuickstartPreferences.getIfIsInFullScreen(this)) {
Log.i("myApp", "is in fullScreen");
}
...
if (myWebView.canGoBack()) {
myWebView.goBack();
}
}
QuickstartPreferences代碼:
public static boolean getIfIsInFullScreen(Activity myActivityReference) {
boolean fullScreen = (myActivityReference.getWindow().getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0;
return fullScreen;
}
我使用'canGoBack()''中onKeyDown()'帶'myWebView.goBack()' –