You can use webview with form and intercept the post data as below:
Create a html form
Use Javascript and bind it to your android code to intercept the form data:
Enable Javascript :
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
Binding JavaScript code to Android code:
create javascript interface class:
public class WebAppInterface {
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String name , String email) {
Toast.makeText(mContext, String.format("Name:%s - Email:%s",name,email), Toast.LENGTH_SHORT).show();
}
}
You can bind this class to the JavaScript that runs in your WebView with addJavascriptInterface()
and name the interface Android. For example:
WebView webView = (WebView) findViewById(R.id.webview);
webView.addJavascriptInterface(new WebAppInterface(this), "Android");
HTML and JavaScript that creates a toast message using the new interface when the user clicks submit button:
<script type="text/javascript">
document.forms["frmSubmit"].onsubmit = function(){
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
Android.showToast(name,email);
}
</script>
References:
https://developer.android.com/guide/webapps/webview.html#UsingJavaScript
How to intercept POST data in an android webview
Android, Webview, get submitted form data
Android - how to intercept a form POST in android WebViewClient on API level 4