java.net.UnknownHostException:无法解析主机" my.url"没有与主机名关联的地址

时间:2015-05-21 11:25:24

标签: android web-services

我收到了UnknownHostException的错误。

 try{
           httpParameters = new BasicHttpParams();
           String auth = android.util.Base64.encodeToString((params[0] + ":" + params[1]).getBytes("UTF-8"),Base64.NO_WRAP);

           HttpGet request = new HttpGet("my.url");
           request.addHeader("Authorization", "Basic " + auth);
           request.addHeader("Accept","application/json");

           client = new DefaultHttpClient(httpParameters);

           /*in the next line is when the exception is launched*/
           response = client.execute(request);

           userAuth = EntityUtils.toString(response.getEntity());

           return true;
       }
       catch (Exception e){
           return false;
       }

我还在AndroidManifest.xml中提供了Internet权限

有关如何解决问题的想法吗?

0 个答案:

没有答案