2011-06-23 8 views
0

Androidが新機能です。私は要件を持って、Androidのモバイルからサーバーにデータを送信します。私はHttpClientを使いました。今問題は、それが安全な接続かどうかです。これが安全な方法であることを確認するにはどうすればいいですか?このトピックをガイドしてください:Android:HttpClient Secure

ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); 
nameValuePairs.add(new BasicNameValuePair("user", user.getText().toString())); 
nameValuePairs.add(new BasicNameValuePair("pass", pass.getText().toString())); 

Log.w("log_tag", "User" + user + "Pass" + pass); 
//http post 
try{ 
    HttpClient httpclient = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost("http://192.168.1.173/android/androidTest.php"); 
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
    HttpResponse response = httpclient.execute(httppost); 
    Log.w("log_tag", "====" + user + "====" + pass); 
    HttpEntity entity = response.getEntity(); 
    // is = entity.getContent(); 

    Intent intent = new Intent(); 
    intent.setClass(this,Result.class); 
    intent.putExtra("user", user.getText().toString()); 
    intent.putExtra("pass", pass.getText().toString()); 
    startActivity(intent); 

}catch(Exception e){ 
    Log.e("log_tag", "Error in http connection "+e.toString()); 
} 

答えて

1

「安全」とはどういう意味ですか? SSLは可能でしょうか?または?安全な接続が必要な場合は、SSLを使用してください。

+0

ありがとうございます。データを保存するためにSecure接続を使用しますか? SSL証明書を取得するには?あなたは一歩一歩教えてくれますか? –

+0

この http://stackoverflow.com/questions/995514/https-connection-android http://stackoverflow.com/questions/2012497/accepting-a-certificate-for-https-上の多くの議論があります。 on-android –

+0

ありがとうございます。私のappicationはapkです。アンドロイドWebアプリケーションではありません。データを保存するために、安全な接続を使用したいのですか? SSL証明書を取得するには?あなたは一歩一歩教えてくれますか? –