我从 http://developer.android.com/guide/webapps/webview.html. 中找的这段代码。使用这段代码进入web 视图后,但是不能退出web 视图,除非我快速的点击两次返回按钮。有办法可以点击返回按钮一次就退出web视图?
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// Check if the key event was the BACK key and if there's history
if ((keyCode == KeyEvent.KEYCODE_BACK) && myWebView.canGoBack() {
myWebView.goBack();
return true;
}
// If it wasn't the BACK key or there's no web page history, bubble up to the default
// system behavior (probably exit the activity)
return super.onKeyDown(keyCode, event);
}