Java 将cookie传递到Android浏览器的Firefox
我有一个在我的服务器上执行post请求的方法,如果成功,我的服务器将返回一个cookieJava 将cookie传递到Android浏览器的Firefox,java,android,firefox,android-intent,cookies,Java,Android,Firefox,Android Intent,Cookies,我有一个在我的服务器上执行post请求的方法,如果成功,我的服务器将返回一个cookie List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); nameValuePairs.add(new BasicNameValuePair("username", uname)); nameValuePairs.add(new BasicNameValu
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("username", uname));
nameValuePairs.add(new BasicNameValuePair("password", passwd));
try {
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Execute HTTP Post Request
try {
response = httpclient.execute(httppost);
List<Cookie> cookiejar = ((AbstractHttpClient) httpclient).getCookieStore().getCookies();
for (Cookie c : cookiejar)
{
cookiename=c.getName();
coo = c.getValue();
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
有人能帮我找出哪里出了问题吗 您能否提供指向
intent.putExtra(“args”,”--url=“+url1”)的firefox文档的链接;intent.putExtra(“args”,“Cookie”+coo)代码>?此外,就我所知,“args”不能有两个“putExtra()”,只有最后一个会保留。我发现这是不可能的,firefox不允许如上所述直接插入Cookie,因为这可能会导致安全漏洞。谢谢大家。
Intent intent = new Intent(Intent.ACTION_VIEW, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setComponent(new ComponentName("org.mozilla.firefox", "org.mozilla.firefox.App"));
intent.setAction("org.mozilla.gecko.BOOKMARK");
//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.putExtra("args", "--url=" + url1 );
intent.putExtra("args", "--Cookie" + coo );
intent.setData(Uri.parse(url1));
Bundle b = new Bundle();
b.putBoolean("new_window", true); //sets new window
intent.putExtras(b);
startActivity(intent);
}