I try to retrieve a picture from e.g
http://graph.facebook.com/btaylor/picture
using the following code:
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet request = new HttpGet(urlString);
HttpResponse response = httpClient.execute(request);
return response.getEntity().getContent();
but occasionally I get the exception
java.net.UnknownHostException: profile.ak.fbcdn.net
Why is this?
Edit: by "occasionally", I mean that it happens often enough that I know the reason is not "My internet 开发者_运维问答is down" or "Facebook is down."
If your device is connected on WiFi, could be due to this issue where the WiFi enters sleep mode.
http://www.boygeniusreport.com/2010/07/14/some-nexus-one-users-experiencing-wi-fi-connectivity-issues/
In my case, I see in the log:
D/WifiService( 1087): setting ACTION_DEVICE_IDLE timer for 900000ms
Then 15 minutes later, the WiFi is turned off.
Using an emulator, there are some known network limitations, However on device it works fine. So, are you using an emulator?
This was happening when I was testing in Simulator if I had a VPN connection open on the machine I was running the simulator on. Once I disconnected from VPN the exception is no longer generated
精彩评论