Reputation: 121
I'm trying to connect to REST web server and I don't know what is going wrong. The code that connects is:
public List<Agenda> getAgenda(String dia) {
try {
Log.i(TAG, "It is inside getAgenda()");
HttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(Settings.getServiceUrl() + "/" + dia);
Log.i(TAG, Settings.getServiceUrl() + "/" + dia);
//the line above prints: http://192.168.0.100/odonto/agenda.php/2012-02-01
HttpResponse resp = client.execute(method);
//return loadFromJSONArray(client.execute(method));
Log.i(TAG, "Recebeu a response");
return loadFromJSONArray(resp);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
Well, here is the thing: the line
Log.i(TAG, Settings.getServiceUrl() + "/" + dia);
prints on the debug window correctly. But the line:
Log.i(TAG, "Recebeu a response");
don't prints. So the problem is in line:
HttpResponse resp = client.execute(method);
But I really don't know how can this be wrong!! I've already tested the REST server with Firefox and it works just fine! The debug window with a filter to show just the tag System.err is in the link:
Upvotes: 0
Views: 426
Reputation: 6128
You are getting permission denial error. Please add below permission in menifest file after application tag
<uses-permission android:name="android.permission.INTERNET"/>
Upvotes: 1