2016-11-18 1 views
-1

localhost 서버의 URL "http://xx2/postdata/DATA2.asp?count=1&CIHAZID=53&ISLEMZAMANI=18102016190815&GZBHID=28198"을 호출하기 위해 AsychTask 기능을 사용하고 있습니다. 올바로 작동하는 이더넷 연결로 안드로이드 장치에서 디버깅하는 동안 "OK"응답 대신 UnKnownHostException을 생성합니다.java.net.UnknownHostException : 호스트 "<url here>"을 확인할 수 없습니다. 호스트 이름과 연결된 주소가 없습니다

"매니페스트에 인터넷 및 네트워크 액세스 권한을 추가하는 등 다른 사이트 및 페이지에서 언급 된 모든 솔루션을 시도했습니다. 파일 "또는"targetSdkVersion을 22로 변경하십시오. "등

인터넷 권한이 이미 매니페스트 파일에 설정되어 있습니다.

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

안드로이드 장치의 브라우저에서 URL을 호출하면 응답으로 "확인"되지만 응용 프로그램은 그렇지 않습니다. 다음은 내가 호스트 xx2를 해결할 수 수없는 말한다 로그에서 URL을

// AsyncTask Function to send TempReports Table records to server 
private class sendLogsToServer extends AsyncTask<String, Void, String> { 

    @Override 
    protected void onPreExecute() { 
     super.onPreExecute(); 
    } 

    @Override 
    protected String doInBackground(String... params) { 

     URLConnection feedUrl; 
     StringBuilder sb = new StringBuilder(); 
     try { 
      feedUrl = new URL(params[0]).openConnection(); 
      InputStream is = feedUrl.getInputStream(); 

      BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); 
      String line = null; 

      while ((line = reader.readLine()) != null) { 
       sb.append(line + ""); 
      } 
      is.close(); 

      //createUserPageResult = sb.toString(); 
      return sb.toString(); 

     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

     return null; 
    } 

    @Override 
    protected void onPostExecute(String result) { 
     super.onPostExecute(result); 
     // if Response from server is OK, then delete the entry from DB TempReports Table 
     if (result != null) { 
      if (result.equals("OK") || result.equals("updated")) { 
       //Toast.makeText(MainActivity.this, "Deleted", Toast.LENGTH_SHORT).show(); 
       posDatabase.tempLogsDelete(logToDelete); 
      } 
     } else { 
      // don't delete 
      //Toast.makeText(MainActivity.this, "NOT Deleted", Toast.LENGTH_SHORT).show(); 
     } 
    } 
} 

전화를 사용하고 AsyncTask를 기능입니다. 다음은 더 명확하게하기위한 로그입니다.

11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err: java.net.UnknownHostException: Unable to resolve host "xx2": No address associated with hostname 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at java.net.InetAddress.lookupHostByName(InetAddress.java:424) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at java.net.InetAddress.getAllByName(InetAddress.java:214) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:70) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpConnection.<init>(HttpConnection.java:50) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpConnection$Address.connect(HttpConnection.java:340) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpConnectionPool.get(HttpConnectionPool.java:87) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpConnection.connect(HttpConnection.java:128) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpEngine.openSocketConnection(HttpEngine.java:316) 
11-18 15:30:32.280 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpEngine.connect(HttpEngine.java:311) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpEngine.sendSocketRequest(HttpEngine.java:290) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpEngine.sendRequest(HttpEngine.java:240) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:282) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:177) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at com.emiturk.pos.MainActivity$sendLogsToServer.doInBackground(MainActivity.java:507) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at com.emiturk.pos.MainActivity$sendLogsToServer.doInBackground(MainActivity.java:493) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at android.os.AsyncTask$2.call(AsyncTask.java:287) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at java.util.concurrent.FutureTask.run(FutureTask.java:234) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at java.lang.Thread.run(Thread.java:856) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err: Caused by: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.io.Posix.getaddrinfo(Native Method) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at libcore.io.ForwardingOs.getaddrinfo(ForwardingOs.java:59) 
11-18 15:30:32.290 13867-14241/com.emiturk.pos W/System.err:  at java.net.InetAddress.lookupHostByName(InetAddress.java:405) 
11-18 15:30:32.300 13867-14241/com.emiturk.pos W/System.err: ... 21 more 
+0

기본 URL 문제는 브라우저에서 기본 URL을 확인하십시오. 날씨가 작동하는지 여부는 – Vadivel

+0

입니다. 코드가있는 URL은 어디입니까? – Vadivel

+0

호스트 이름 "xx2"를 인식하고있는 DHCP 서버입니까? 'adb ​​shell '을 사용하여 abd를 통해 장치에 연결 한 다음'ping xx2'를 입력하여이 작업을 수행하십시오. 결과는 xx2가 알려지지 않았 음을 보여줄 것입니다. – andred

답변

0

당신은, 당신의 로컬 호스트는 xx2라는 (아마 데스크톱 PC는 홈 네트워크 인프라의 서버 역할) URL이 로컬 호스트에서 제공되는 언급?

예를 들어 IP를 통해 액세스해야합니다. http://192.168.1.1/....인데, 귀하의 안드로이드 기기가 xx2이라는 이름이 서버의 IP로 해석된다는 사실을 모르기 때문입니다.

관련 문제