Network Unreachable ( 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 ( 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 ( 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
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. How to use the LevelListDrawable class


I am trying to use the LevelListDrawable class in order to control a
sequence of images for a timer.  The problem that I am having is that
the setLevel() method is having no effect on the displayed image.  The
only image that is displayed in the UI is the first image in the
list.  According to documentation:

[Setting the level value of the object with setLevel(int) will load
the image with the next greater or equal value assigned to its max

The documentation also states:

[With this XML saved into the res/drawable/ folder of the project, it
can be referenced as the drawable for an ImageView. The default image
is the first in the list. It can then be changed to one of the other
levels with setImageLevel(int).]

I am a bit confused as to whether I need to call setLevel() on the
LevelListDrawable object, or if I need to call setImageLevel() on an
ImageView object that references the LevelListDrawable, or if I need
to do both. I have explored each of these options but none of which
caused the displayed image to change.

My xml file (seconds.xml) that describes the behavior of the
LevelListDrawable is as follows:

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android=""
     <item android:maxLevel="9" android:drawable="@drawable/digit9" />
     <item android:maxLevel="8" android:drawable="@drawable/digit8" />
     <item android:maxLevel="7" android:drawable="@drawable/digit7" />
     <item android:maxLevel="6" android:drawable="@drawable/digit6" />
     <item android:maxLevel="5" android:drawable="@drawable/digit5" />
     <item android:maxLevel="4" android:drawable="@drawable/digit4" />
     <item android:maxLevel="3" android:drawable="@drawable/digit3" />
     <item android:maxLevel="2" android:drawable="@drawable/digit2" />
     <item android:maxLevel="1" android:drawable="@drawable/digit1" />
     <item android:maxLevel="0" android:drawable="@drawable/digit0" />

My main activity is setting up the ImageView object is currently setup
like this:

public void onCreate(Bundle savedInstanceBundle)
LinearLayout layout = new LinearLayout(this);
ImageView m_secondsView = new ImageView(this);
m_secondsView.setImageLevel(4); // for testing purposes let's try to
change the UI

I assume I am missing some important piece of how this class is
supposed to be used but haven't been able to figure it out yet.  Any
help would be much appreciated.



2. How to achieve transparency for a new activity

Hi all,
         I  wanted to keep by background transparent when I open new
activity on half of the screen.

I coded like this,

<style name="Mytheme">
<item name="android:windowBackground">@android:color/transparent</
<item name="android:windowFrame">@null</item>
<item name="android:backgroundDimAmount">0.6</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsTranslucent">false</item>

and i got it on emulator  but when i deployed on Hardware it is not
working..even it is not working on emulator itself..


3. When I try to use DefaultHttpClient to access https server via proxy, an IllegalArgumentException will be thrown, why?

4. Typos in 1.5 r2 DevGuide>Graphics timestamp 02 Jun 2009 12:17

5. linearlayout does not allow vertical scroll after adding dynamic edittexts

6. Question on MMS-supported media types

7. Where can I find the source code of camcorder application on g1 phone?