Monday, October 10, 2011

Permission denied error while call webservice using HTTP in android application

Error:

I'm working in android application.I create a web service in java.Now i want to refer a webservice using HTTP. but i got 'Permission Denied' Error while the debugger reached the last line. The Code is,
HttpClient httpClient = new DefaultHttpClient(); HttpContext localContext = new BasicHttpContext(); HttpGet httpGet = new HttpGet("http://192.168.0.102:8282/SampleWebProj/services/Converter"); response = httpClient.execute(httpGet, localContext);

Solution :

Have you added the correct permissions on AndroidManifest.xml to open http connections?
I think, you have to add this permission
<uses-permission android:name="android.permission.INTERNET"></uses-permission>

The only trick is that you have to adjust the AndroidManifest.xml file to allow the application to access the internet.  Here's the entry you need to add (put it right after the application element closing tag (</application>)...
   
   <uses-permission android:name="android.permission.INTERNET">
   </uses-permission>

No comments: