-8
我已經搜索了網頁,無濟於事,我找到了解決問題的答案。Android開發:如何通過https創建網絡登錄
我需要我的android應用程序連接到我的web服務器。
例如https://SERVER-ADDRESS:PORT/
我怎樣才能做到這一點?
我已經搜索了網頁,無濟於事,我找到了解決問題的答案。Android開發:如何通過https創建網絡登錄
我需要我的android應用程序連接到我的web服務器。
例如https://SERVER-ADDRESS:PORT/
我怎樣才能做到這一點?
try{
String url = "https://SERVER-ADDRESS:PORT/site/login?username=" + user + "&password=" + password;
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setConnectionTimeout(params, 1000 * 60 * 2);
HttpConnectionParams.setSoTimeout(params, 0);
HttpClient httpClient = new DefaultHttpClient(params);
//prepare the HTTP GET call
HttpGet httpget = new HttpGet(url);
//get the response entity
HttpEntity entity = httpClient.execute(httpget).getEntity();
if (entity != null) {
//get the response content as a string
String response = EntityUtils.toString(entity);
//consume the entity
entity.consumeContent();
// When HttpClient instance is no longer needed, shut down the connection manager to ensure immediate deallocation of all system resources
httpClient.getConnectionManager().shutdown();
}
}catch (Exception e) {
e.printStackTrace();
}
嘿,這太棒了!我怎樣才能讓用戶不得不輸入他們自己的用戶名和密碼。併發送以下http請求https:// SERVER-ADDRESS:PORT/site/login? 用戶名= USER&密碼= PASS –
字符串URL = 「https://開頭SERVER-ADDRESS:PORT /站點/登錄用戶名=」 +用戶+ 「&密碼=」 +密碼; – Nermeen
非常感謝,這非常有幫助! –