相关疑难解决方法(0)

Android WebView Cookie问题

我有一个服务器,它向我的Android应用程序发送一个会话cookie,用于认证通信.我正在尝试使用指向同一服务器的URL加载WebView,并且我正在尝试传递会话cookie以进行身份​​验证.我观察到它间歇性地工作,但我不知道为什么.我使用相同的会话cookie在我的服务器上进行其他调用,这些调用永远不会失败.我只是在尝试在WebView中加载URL时才发现此问题,并且每次都不会发生这种情况.很沮丧.

下面是我用来执行此操作的代码.任何帮助将不胜感激.

String myUrl = ""http://mydomain.com/"; 
CookieSyncManager.createInstance(this); 
CookieManager cookieManager = CookieManager.getInstance(); 
Cookie sessionCookie =  getCookie(); 
if(sessionCookie != null){ 
    String cookieString = sessionCookie.getName() +"="+sessionCookie.getValue()+"; domain="+sessionCookie.getDomain(); 
    cookieManager.setCookie(myUrl, cookieString); 
    CookieSyncManager.getInstance().sync(); 
} 

WebView webView = (WebView) findViewById(R.id.webview); 
webView.getSettings().setBuiltInZoomControls(true); 
webView.getSettings().setJavaScriptEnabled(true); 
webView.setWebViewClient(new MyWebViewClient()); 
webView.loadUrl(myUrl);
Run Code Online (Sandbox Code Playgroud)

cookies android webview

82
推荐指数
5
解决办法
14万
查看次数

如何拦截android webview中的POST数据

我有一个包含webview的Android应用程序.它需要允许用户在网页上填写表单,然后在用户单击表单后更改表单的数据submit.表单将使用POST请求方法.

所以我的问题是,如何从表单中截取POST数据,更改它的值,然后发送它?

例如:如果有这样的Web表单......

<form action="http://www.example.com/do.php" method="post">
    <input type="text" name="name" />
    <input type="text" name="email" />
    <input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)

如果用户在表单中输入name = Steve和email = steve@steve.com,我想在android应用程序中将值更改为name = bob和email = bob@bob.com并将新POST发送给http://www.example.com/do.php.

谢谢你的帮助!

post android http webview

29
推荐指数
1
解决办法
3万
查看次数

将Cookie设置为Android中的webView

HttpResponse在检查用户名或密码是否正确时从服务器获取.当我加载url一个webview我想要webView有cookie(我得到的答案postData()存储在webView.我希望webView获取cookie并加载存储在webview中的cookie的URL.

我正在收到回应.

public HttpResponse postData() {
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("https://example.com/login.aspx");

    try {
        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
        nameValuePairs.add(new BasicNameValuePair("txtUsername", "user"));
        nameValuePairs.add(new BasicNameValuePair("txtPassword", "123"));
        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

        HttpResponse response = httpclient.execute(httppost);
        String responseAsText = EntityUtils.toString(response.getEntity());
        Log.v(TAG , "Response from req: " + responseAsText);
        return responseAsText;

    } catch (ClientProtocolException e) {

    } catch (IOException e) {

    }
    return null;
}
Run Code Online (Sandbox Code Playgroud)

我用loadUrl:

webView.loadUrl("http://a_page.com/getpage.aspx?p=home");
Run Code Online (Sandbox Code Playgroud)

我想我不是真正管理一个cookie,我不知道该怎么做.任何建议或解决方案?

cookies post android http

19
推荐指数
5
解决办法
7万
查看次数

如何使用webview发布帖子请求?

我想使用webview发出http发布请求.

webView.setWebViewClient(new WebViewClient(){


            public void onPageStarted(WebView view, String url,
                Bitmap favicon) {
            super.onPageStarted(view, url, favicon);
            }

            public boolean shouldOverrideUrlLoading(WebView view,
                String url) {

            webView.postUrl(Base_Url, postData.getBytes());

            return true;
            }

        });
Run Code Online (Sandbox Code Playgroud)

上面的代码段加载了网页.我想访问此请求的响应.

如何使用webview获取http post请求的响应?

提前致谢

android response http-post webview

6
推荐指数
2
解决办法
2万
查看次数

将数据发送到WebView中加载的页面

我的应用程序中有一个WebView,我加载了http://mysite.com/somepage.php

我知道我可以使用GET方法传递数据,因为这恰好在URL字符串中.我想知道如何使用POST方法将数据传递到页面.我试过搜索,但找不到具体的东西.谢谢.

post android http-post webview

5
推荐指数
1
解决办法
7429
查看次数

标签 统计

android ×5

webview ×4

post ×3

cookies ×2

http ×2

http-post ×2

response ×1