如何从机器人的WebView URL POST参数onPageStart()方法 [英] How to get POST parameters from android webview's URL in onPageStart() method

查看:1068
本文介绍了如何从机器人的WebView URL POST参数onPageStart()方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以及我米制作的Andr​​oid和iPhone的应用程序的WebView

well I m making an webview app for android and Iphone.

在Android的我米面临的一个问题

In android I m facing an Issue

我有这样的习俗WebviewClient网页视图

I have a webview with custom WebviewClient like this

webView.setWebViewClient(new MyWebViewClient());

这里是我的自定义WebviewClient类

here is my Custom WebviewClient class

private class MyWebViewClient extends WebViewClient {

    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {

        if (url.equalsIgnoreCase(MyConstants.fb_share)) {
            view.stopLoading();

                            //Want to get POST parameters embedded with the url. 

            Intent i = new Intent(context, FaceBookActivity.class);
            i.putExtra("FB_SHARE_URL", url);
            startActivity(i);

        }

        super.onPageStarted(view, url, favicon);
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        loadedUrl = url;

        return super.shouldOverrideUrlLoading(view, url);
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);


    }
}

注意:在onPageStarted()方法我米在开始其他活动。但在这里,我想获得的URL的POST参数。有没有方法来获取嵌入的URL后的参数。

note: in onPageStarted() method I m starting an other activity. but here I want to get the POST parameters with the url. is there any method to get the post parameters embedded with the url.

在iPhone,这是有可能得到POST URL参数。
请帮我对此的机器人。

In Iphone this is possible to get POST url parameters. Please help me for android regarding this.

感谢

推荐答案

重要的是要做到这一点(看POST数据)采用了Android的WebView,因为它不会让你看数据是不可能被发送到服务器。你可以重新编写的JavaScript捞出输入字段的值的页面(或更改方法来获得),但与处理两种方法的图像可能不会是微不足道的。

It's not possible to do this (look at POST data) using the Android WebView since it doesn't allow you to look at the data being sent to the server. You could re-write the page with JavaScript fish out the values of the input fields (or change the method to GET) but handling images with either method will probably not be trivial.

既然你写的我不知道'嵌入的URL POST参数'如果表单使用方法='得到',在这种情况下,看看这个答案:的 Java中解析查询字符串

Since you write 'POST parameters embedded with the url' I wonder if the form is using method='get', in which case take a look at this answer: Parsing query strings in Java

另外,不要叫 stopLoading onPageStarted ,那将会在比赛结束。使用 shouldOverrideUrlLoading 为(刚刚从那里返回,而不是调用真正的 stopLoading )。

Also, don't call stopLoading from onPageStarted, that's going to end in a race. Use shouldOverrideUrlLoading for that (just return true from there instead of calling stopLoading).

这篇关于如何从机器人的WebView URL POST参数onPageStart()方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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