如何使用WebView.goBack()方法时重新发送POST数据? [英] How to resend POST data when using WebView.goBack() method?

查看:2062
本文介绍了如何使用WebView.goBack()方法时重新发送POST数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里,我们提供用户与导航回的网页用户选择一个应用程序的工作有previously查看。

I am working on an application where we are providing user with the option to navigate back to the webpages user has previously viewed.

当用户导航回载有POST数据的页面,就会出现问题。

The problem arises when user navigates back to a page which contained POST data.

我不知道如何检测,在web视图加载页面有POST数据,以便应用可以提示一个确认对话框,如果他想重新发送POST数据或没有。

I don't know how to detect that the page loaded in the WebView had POST data so that app can prompt a confirm dialog, if he wants to resend the POST data or not.

我已经看到这种情况发生在Android浏览器[原生浏览器与天火]

I have seen this happening in android browsers [Native browser & Skyfire]

在此先感谢...

推荐答案

在研究好几天我创建了一个变通方法来摆脱这种局面。

After several days of research i created a workaround to get rid of this situation.

我设置标志时WebView.goback()被调用.....

I am setting a flag when WebView.goback() is called.....

在我onProgressChanged()方法我检查,如果要加载的网址与它应该包含POST数据的URL匹配,我叫WebView.reload()及我的标志设置为false,也是我重写WebViewClient的方法叫做: onFormResubmission(的WebView视图,信息dontResend,信息重发)

In my onProgressChanged() method i check if the url being loaded matches with the url which should contain POST DATA, i call WebView.reload() & set my flag to false and also i Override a method of WebViewClient called : onFormResubmission (WebView view, Message dontResend, Message resend)

其中的主体包括:

resend.sendToTarget();

        @Override
    public void onFormResubmission (WebView view, Message dontResend,Message  resend){

        resend.sendToTarget();
    }

有关更详细的信息,请访问:的 HTTP://mytechead.word$p$pss.com/2012/03/08/resubmit-post-data-in-a-webview/

for more detailed information visit : http://mytechead.wordpress.com/2012/03/08/resubmit-post-data-in-a-webview/

这篇关于如何使用WebView.goBack()方法时重新发送POST数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆