Network Unreachable (Socket.net Exception)

by Frank Weiss » Sun, 07 Feb 2010 11:15:10 GMT


Sponsored Links
 Re your question about implementing a service that polls for updates, please
look at some of the sample code. For example, Romain Guy's Photostream demo
application has a background service that polls the Flikr API webservice for
updates and displays a notification in the notification bar. AFAIK whether
the access is by phone network or WiFi is functionally irrelevant.

--



Network Unreachable (Socket.net Exception)

by Frank Weiss » Mon, 08 Feb 2010 09:07:22 GMT


 Is the service completely crashing due to the exception or does the service
continue to get the exception subsequently? Are you perhaps wrongly assuming
that the phone is connected to the internet whenever you want it to be?

--


Sponsored Links


Network Unreachable (Socket.net Exception)

by Frank Weiss » Mon, 08 Feb 2010 10:50:10 GMT


 The network unreachable error is always a networking problem. Could be the
local network interfaces (wifi and phone) are turned off or temporarily
disabled, a bad network mask setting, or some router is unable to route an
IP address. It may also be an ipv6 config error. It may be occuring while
trying to resolve DNS (DNS server is unreachable). I have some suggestions:

1) Describe the network environment: emulator or device (which device) WiFi
on or off, wireless network carrier, local network configuration, including
firewalls (if using emulator or WiFi).
2) Test the application in a different network environment (home, office,
friend's house, cafe).
3) Add code that when the exception occurs, tries to access the network by
some other means besides HttpUrlConnection.
4) As 3), but try using a different Android application that accesses the
internet.
5) Try using an IP address instead of hostname.
6) I forgot to add, once the error occurs, how do you get the service to
connect again?

--



Other Threads

1. Extending Drawable Class

Hello,

I'm fairly new to Android development, and having a couple of
questions concerning extending the Drawable class. I see that the draw
method has an abstract modifier. However, while looking at the Lunar
Lander example code, I noticed that several of the images being drawn
to the screen are of the Drawable type. How is this possible, since
the draw method is abstract?

Also, I tried extending the Drawable class into a Sprite class to
handle some additional properties and methods I need for a video game,
but I get a runtime ClassCastException error whenever I try to get a
Drawable resource from my Resources and cast it as a Sprite, like so:

private Sprite mSpriteImage;
mSpriteImage = (Sprite) context.getResources().getDrawable
(R.drawable.testSprite);

How would I go about making this work?

Thanks.

--~--~---------~--~----~------------~-------~--~----~

2. Refreshing a specific list-item in ListView

Hey folks,

Simple situation:
- ListActivity with an adapter that inflates a small view for each
list item.

Part of each list-item is an ImageView that might need to be populated
by a thumbnail that is pulled across the network (and then
subsequently cached). I intend to do the fetching in a separate
AsyncTask and to cache a reference to the specific ImageView to be
populated within the AsyncTask. This didn't seem to work (images got
added into the wrong list-items). I suspect it's because I'm reusing
the "convertView" Views that are passed into getView() on my adapter,
and by the time the thumb is downloaded, the ImageView reference I've
cached is now in re-use by a different list-item (can someone
confirm?).

The alternative would be to have a notification mechanism for a
specific *position* in a list, but there doesn't seem to be a way of
notifying a specific list-item to update itself. Searching for
[refresh specific list item] brings up this bug:
http://code.google.com/p/android/issues/detail?id=227, but I don't
know if there's been any progress on that.

Any ideas? Let me know if there's any other information I should
provide.

Thanks!
Aaron

--~--~---------~--~----~------------~-------~--~----~

3. Android Podcasts at Google I/O?

4. Using Google protobufs on Android

5. about the macro nested classes

6. Visual tools for designing the application layout

7. Place Video on SD Card (during app's Initial Marketplace purchase/Installation)