WebView on Android: Auto-focus on a textfield to pop-up keyboard upon arrival at page

Use case

Automatically focus on a text field in a WebView so that the keyboard pops up immediately. This makes it easier for the user to interact with the form.

Problem

The usual JavaScript technique doesn’t work on Webviews. Apple (and I think Google) prefer that the keyboard pops up in response to a user tap, not without user interaction. We need it to pop up upon arrival at the page.

Solution

The lines in the screen grab fix the problem in Java.
Add a method to the webview allowing us to specify a form element to focus.

eg

webview.requestFocus('DOM_name_of_text_element')