的HttpClient不存儲Cookie我試圖從服務器與此代碼銀河S2
DefaultHttpClient httpClient = new DefaultHttpClient();
httpClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT, USER_AGENT);
HttpRequestRetryHandler retryhandler = new DefaultHttpRequestRetryHandler(6, true);
httpClient.setHttpRequestRetryHandler(retryhandler);
BasicCookieStore cookieStore = new BasicCookieStore();
httpClient.setCookieStore(cookieStore);
if(Build.VERSION.SDK_INT>8){
CookieManager cookieManager = new CookieManager();
cookieManager.setCookiePolicy(CookiePolicy.ACCEPT_ALL);
CookieHandler.setDefault(cookieManager);
}
HttpGet httpget = new HttpGet(URL);
HttpResponse response = httpClient.execute(httpget);
HttpEntity entity = response.getEntity();
...
它的正常工作與所有我想到目前爲止,除了三星Galaxy SII的設備(Android 4.0的獲取數據。 3)我的客戶。從服務器響應,似乎會話cookie不存儲。我沒有重現這個錯誤,我迄今爲止所嘗試的所有東西都沒有解決。你有任何線索嗎?
編輯:刪除的誰被禁用StrictMode政策(仍然有問題壽)
您是否在單獨的線程/ asynctask上執行連接? –
是的,我在asynctask上啓動它。線程策略不再需要。感謝您突出顯示:) –
是的..你def不應該只是禁用StrictMode ... StrictMode是有原因的:)。 –