Reputation: 195
Hey everyone, I'm working on an Android App in Eclipse, and getting a wierd exception that I'm having trouble nailing down. The exception occurs in:
public int getEvents(){
NodeList property_nodes;
NodeList event_nodes;
InputStream is;
parserFactory = DocumentBuilderFactory.newInstance();
try{
parser = parserFactory.newDocumentBuilder();
//check the last updated date
get = new HttpGet("http://whatever.com/test_date.php");
response = client.execute(get);
entity = response.getEntity();
...
at the client.execute(get) line. It's caught by,
} catch (Exception e){
String e_cause = e.getMessage();
return -1;
}
and e_cause is just "whatever.com" and nothing else. This exact code was working earlier today, and I can't figure out how to diagnose this further! Does anyone know why the exception would return a URL from the getMessage function, or a way to get more information about the source of the error?
Thanks so much.
Upvotes: 1
Views: 890
Reputation: 195
Thanks for the responses everyone. The problem was that my emulator had disconnected from my network for some reason. I left it open for a couple hours while doing something else, then came back to it, and it wasn't connecting. I re-opened the emulator, and everything worked fine. I probably should have tried that first...
Upvotes: 0
Reputation: 21335
two possible reasons. you need to set permission in Manifest to access the Internet. there is a permission for this. The other reason is the network you are on cannot find the domain name so trying pinging the address to get the ip address of the website and just put that in instead of the domain name. So if www.somesite.com/abc use ipaddress/abc instead. that should solve it.
Upvotes: 3