Android & Wordpress Help center

Resubmit POST DATA in a webview

After working for nearly 15 hours and googling with almost all the possible combination of keywords, finally i came across a WORKING method to re-submit POST DATA contained in a webview.

Background :
I am working on an app that contains webview. This webview has a ‘refresh’, ‘go-forward’ & ‘go-backward’ buttons in the toolbar. Now the webview also has a query box that submits POST DATA to a url.

Now the issue that i was facing was when the user submits POST DATA to the url and then hits the refresh button on the results screen i was getting no data, the reason was pretty simple, the data that user has entered previously was POST DATA so there was no way that the normal WebView.reload() is going to detect that post data.

Create a nested class inside your activity which extends WebViewClient class of android and Override a method in that class, called – onFormResubmission (WebView view, Message dontResend, Message resend)

Inside the method onFormResubmission() make a call to sendToTarget() mehtod like this :

Code snippet:

private class mWebViewClient extends WebViewClient{
public void onFormResubmission (WebView view, Message dontResend, Message resend){

L.v("### FORM ","## FORM RE SUBMIT");
Toast.makeText(getApplicationContext(), "RESUBMIT DATA", Toast.LENGTH_LONG).show();


Single Post Navigation

3 thoughts on “Resubmit POST DATA in a webview

  1. thanks.very good blog and very good share.

  2. Excellent! Thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: