Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用安全SSL连接保留会话_Java_Android_Session_Ssl_Https - Fatal编程技术网

Java 使用安全SSL连接保留会话

Java 使用安全SSL连接保留会话,java,android,session,ssl,https,Java,Android,Session,Ssl,Https,在那里,我连接到授权页面,进入帐户并加载主页。 如何在不丢失连接的情况下下载帐户中的其他页面? 这是对的吗 主要类别: HttpParams httpParameters=new BasicHttpParams(); int timeoutConnection=10000; HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection); int timeoutSocket=10000; HttpConnec

在那里,我连接到授权页面,进入帐户并加载主页。 如何在不丢失连接的情况下下载帐户中的其他页面? 这是对的吗

主要类别:

HttpParams httpParameters=new BasicHttpParams();
int timeoutConnection=10000;
HttpConnectionParams.setConnectionTimeout(httpParameters,timeoutConnection);
int timeoutSocket=10000;
HttpConnectionParams.setSoTimeout(httpParameters,timeoutSocket);
HttpClient客户端=新的MyHttpClient(httpParameters,getApplicationContext());
HttpPost请求=新建HttpPost(“https://some.com/Login.aspx");
BufferedReader in=null;
试一试{
List nameValuePairs=新的ArrayList(2);
添加(新的BasicNameValuePair(“uname”、“name”);
添加(新的BasicNameValuePair(“upass”、“pass”));
setEntity(新的UrlEncodedFormEntity(nameValuePairs));
HttpResponse response=client.execute(请求);
in=新的BufferedReader(新的InputStreamReader(response.getEntity().getContent());
StringBuffer sb=新的StringBuffer(“”);
字符串行=”;
字符串NL=System.getProperty(“line.separator”);
而((line=in.readLine())!=null){
sb.追加(行+NL);
}
in.close();
字符串页=sb.toString();
textview.setText(第页);
}catch(ClientProtocolException e){…}
和MyHttpClient类:

公共类MyHttpClient扩展了DefaultHttpClient
{    
最终语境;
公共MyHttpClient(HttpParams hparms,上下文)
{
超级(hparms);
this.context=上下文;
}
@凌驾
受保护的ClientConnectionManager createClientConnectionManager(){
SchemeRegistry registry=新SchemeRegistry();
register(新方案(“http”,PlainSocketFactory.getSocketFactory(),80));
register(新方案(“https”,neweasysslsocketfactory(),443));
返回新的SingleClientConnManager(getParams(),注册表);
}
}

使用相同的请求对象(HttpPost),它应该使用相同的连接,除非您显式地对其调用releaseconnection。参考

我做到了!在登录时,我使用HttpPost,并认为它必须用于转到其他页面,但正如我看到的,我使用“magic plugin”打开了Firefox的第二个页面,其中包含HttpGet和configureg headers请求。谢谢