期望如果webview可返回就返回到webview的上一个页面,如果webview不可返回则关闭当前activity
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
if (wvTask.canGoBack()) {
wvTask.goBack();
return true;
} else {
onBackPressed();
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onBackPressed() {
if (wvTask.canGoBack()) {
wvTask.goBack();
} else {
finish();
}
}
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/6223.html