Below is click on the return key processing code
WebView. SetOnKeyListener (new View. OnKeyListener () {
@ Override
Public Boolean onKey (View v, int keyCode, KeyEvent event) {
If (event. GetAction ()==KeyEvent. ACTION_DOWN) {
//can press the return key operation and back page
If (keyCode==KeyEvent. KEYCODE_BACK & amp; & WebView. CanGoBack ()) {
//back
/* *
* get back path, if the previous path==portal home page, then jump straight to the home page (prevent't return), or directly to return to previous page
* if it is a heavy load for the mobile computer page page lead to can't return, after the judgment directly before returning the page
*/
WebBackForwardList backForwardList=webView. CopyBackForwardList ();
If (backForwardList!=null & amp; & BackForwardList. GetSize ()!=0) {
//the current page in the history of the positions of the queue
Int currentIndex=backForwardList. GetCurrentIndex ();
WebHistoryItem historyItem.=backForwardList getItemAtIndex (currentIndex - 1);
If (historyItem!=null) {
String backPageUrl=historyItem. GetUrl ();
If (backPageUrl. Equals (" home address ")) {
The v (" record: ", backPageUrl);
WebView. LoadUrl (" home address ");
WebView. PostDelayed (new Runnable ()
{
@ Override
Public void the run ()
{
WebView. ClearHistory ();
}
}, 1000);
} else {
String f_url=webView. GetUrl ();
WebView. GoBack ();
String b_url=webView. GetUrl ();
{if (f_url. Equals (b_url))
WebView. GoBackOrForward (1);
}
}
}
}
} else {
OnBackPressed ();//double return to exit the app
}
}
return true;
}
});