Uncle also said Xamarin ~ Android ~ Listen to the Return key, click back to a webView, double-click to exit, xamarinwebview
This operation is easy to implement in native android, and it is not difficult in xamarin. There is an OnKeyDown method in the activity. We only need to rewrite it, then you can reload the page to be returned through webView. Of course, the operation is somewhat rigid, but it still has a good effect!
The principle of implementation is to set a time in the activity, and assign the time value after clicking and compare it with the current time. If it is within 2 seconds, it is considered as a double-click operation, of course, you can set this interval by yourself. After you think it is a double-click operation, you can execute the Finish () method to return to the main window. Of course, you can also set your own behavior by clicking the operation, in this example, a new page is opened in webView.
DateTime? LastBackKeyDownTime; public override bool OnKeyDown (Keycode keyCode, KeyEvent e) {if (keyCode = Keycode. Back & e. Action = KeyEventActions. Down) {if (! LastBackKeyDownTime. hasValue | DateTime. now-lastBackKeyDownTime. value> new TimeSpan (0, 0, 2) {Toast. makeText (this. applicationContext, "exit the program again", ToastLength. short ). show (); lastBackKeyDownTime = DateTime. now; loadUrl ("/Task/CurrentTaskList");} else {Finish ();} return true;} return base. onKeyDown (keyCode, e );}
For knowledge, accumulation is more important than talent ~ Storage uncle