[英]Unknown Host Exception thrown by HttpClient.execute
i am trying to get data from a webpage on my server.However when i run this code it always fails at httpClient.execute() 我正在尝试从服务器上的网页获取数据。但是,当我运行此代码时,它总是在httpClient.execute()上失败
String flixURL=("http://myserver.com:6718/cgi-bin/log.pl?zip=" + zippy);
Toast.makeText(getBaseContext(),flixURL,5).show();
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(flixURL);
ResponseHandler<String> resHandler = new BasicResponseHandler();
System.out.println("resHandler"+resHandler);
try {
String page = httpClient.execute(httpGet, resHandler);
System.out.println("page"+page);
}
catch (ClientProtocolException e)
{
e.printStackTrace();System.out.println(e);
}
catch (IOException e) {
e.printStackTrace();System.out.println(e);
}
Debugger told me it is possible UnknownHostException. 调试器告诉我,UnknownHostException是可能的。 I have tried different URLs as well still the issues persists.
我尝试了不同的URL,但问题仍然存在。
Android Manifest file is like : Android Manifest文件如下:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.andtwi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".AndTwitterActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".screen2" android:label="Screen2">
</activity>
<uses-permission android:name="android.permission.INTERNET" />
</application>
</manifest>
Can anyone give me hint where is the problem. 谁能给我提示问题出在哪里。 Thanks..
谢谢..
Move this line 移动这条线
<uses-permission android:name="android.permission.INTERNET" />
Outside <application>
tag: 在
<application>
标记之外:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.andtwi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:label="@string/app_name"
android:name=".AndTwitterActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".screen2" android:label="Screen2">
</activity>
</application>
</manifest>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.