I am trying to run an andriod application from emulator , but whenever i send a valid url request it is showing 404 as status code . I have following code.
if i use
http://10.0.2.2/api/ca/entry/?format=json&username=pragya
from emulator browser , it is returning fine.
HttpClient httpclient = new DefaultHttpClient();
HttpGet httppost = new HttpGet("http://10.0.2.2/api/ca/entry/?format=json&username=pragya");
try {
HttpResponse response = httpclient.execute(httppost);
Integer i =response.getStatusLine().getStatusCode();
Toast.makeText(HelloWorldActivity.this, i.toString(), Toast.LENGTH_SHORT).show();
}
EDIT…………….
The manifest file is as below
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.andriod.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloWorldActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
try two thing one shuold be solution
1 – check entry is there in manifest
android.permission.INTERNET2- try to open the same in phone native browser
2-a if get open then it’s fine
2-b if not get open try that url in desktop browser