PHP、mySQL、localhostを使用してAndroidログインアプリを構築しようとしています。ただし、接続の問題が表示されます。エミュレータとAndroidデバイスの両方を試しました。 また、私のWLANのIPアドレスを、ifconfigからifconfigからWireless LAN Adapter Wifi 2で探してみました。私のAndroidデバイスは同じWIFI接続を使用しています(リピーターもありますが、それは私のエミュレータで 'ehostunreach'を表示するために使用されました。と 'ehostunreach' &私のAndroidデバイスの 'etimedout'。 このような詳細があれば十分です。どんな助けでも大歓迎です。ポート10.0.2.2(ポート80)への接続に失敗しました:ETIMEDOUTによるETIMEDOUT
protected String doInBackground(String... params) {
String type = params[0];
String login_url = "http://10.0.2.2/login.php";
if(type.equals("login")) {
try {
String user_name = params[1];
String password = params[2];
URL url = new URL(login_url);
HttpURLConnection httpURLConnection = (HttpURLConnection)url.openConnection();
httpURLConnection.setRequestMethod("POST");
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
OutputStream outputStream = httpURLConnection.getOutputStream();
BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(outputStream, "UTF-8"));
String post_data = URLEncoder.encode("user_name","UTF-8")+"="+URLEncoder.encode(user_name,"UTF-8")+"&"
+URLEncoder.encode("password","UTF-8")+"="+URLEncoder.encode(password,"UTF-8");
bufferedWriter.write(post_data);
........
電話機のブラウザで「http://10.0.2.2/login.php」をテストしましたか?それは開きますか? – W0rmH0le
それはありません。私のPC上で10.0.2.2のpingが失敗しました。他の人が指摘したように、WLAN IPアドレスを使用しようとしました。ピングは成功しましたが、それでも動作しません。 –