Reputation: 300
i am trying to get data from a webpage on my server.However when i run this code it always fails at 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. I have tried different URLs as well still the issues persists.
Android Manifest file is like :
<?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..
Upvotes: 1
Views: 3320
Reputation: 59198
Move this line
<uses-permission android:name="android.permission.INTERNET" />
Outside <application>
tag:
<?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>
Upvotes: 5