当检查用户名或密码是否正确时,我从服务器获取HttpResponse.
当我在网页视图中加载网址时,我希望webView拥有cookie(使用postData()存储在webView中的答案).
我想要webview来取代cookie,并加载该网址存储在webview中的URL.
当我在网页视图中加载网址时,我希望webView拥有cookie(使用postData()存储在webView中的答案).
我想要webview来取代cookie,并加载该网址存储在webview中的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; }
和我loadUrl与:
webView.loadUrl("http://a_page.com/getpage.aspx?p=home");
解决方法
你可能想看看这个解决方案:
Android WebView Cookie Problem
原文地址:https://www.jb51.cc/html/230653.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。