I want my Android application to use Webview to display an html form. When the user presses the Submit button, it want the name/value pairs sent back to my program. How do I do this?
I have looked at other similar questions but not of the responses tell how, specifically, to do this.
Look into the use of Javascript interfaces within WebView. Please see this area of the Android Developers Guide. Basically, you should be able to communicate from the page to the device with the Javascript interface and let your WebView Activity know when the submit button is pressed and send its values over.
I have found what I needed. If I set action='FORM" in the form html, then I can intercept the action with:
public void onLoadResource (WebView view, String url){
int index = url.indexOf("FORM?");
if (index != -1){
String d = URLDecoder.decode(url.substring(index+5));
}
}
The name/value pairs are in String d.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With