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()' –