If your device switches off the networking connection while sleeping, then yes, that line can throw an exception.

It should be an IOException, which should go into the log, but since it doesn't seem to be - add a catch block for Exception (or even better, Throwable) and log it, see what happens.

You could also log the current connectivity state just before opening the connection, just some additional information to see what's going on:

ConnectivityManager cm = (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
NetworkInfo connNetwork = cm.getActiveNetworkInfo();
Log.i(TAG, "Active network info: " + String.valueOf(connNetwork));

-- Kostya

20.02.2011 15:36, Neilz пишет:
Reviving this thread yet again...

There does seem to be some kind of bug in the code. Strange thing is
though, it does get caught. The code always works fine within normal
circumstances, but when it's run as an Alarm Service, the process dies
at a particular line, and it isn't caught in the catch block.

try{
         URL updateURL = new URL(sUrl);
         conn = updateURL.openConnection();
         ins = conn.getInputStream();  // this line causes the process
to die
}catch(IOException ioe){
         Log.e(TAG, "Error making URL request " + ioe.getMessage()); //
this is never shown
         throw ioe;
}

Any ideas why this would happen?

On Feb 7, 9:41 am, Kostya Vasilyev<kmans...@gmail.com>  wrote:

Having said that, there may be a bug in your code. Since your code,
AFAIK, schedules one alarm at a time, there may be a situation where the
old alarm already fired (and forgotten), and the new one isn't
scheduled. You should schedule the new alarm as soon as you receive the
old one. Ideally, right inside onReceive for the old alarm's broadcast
action, because onReceive is guaranteed to not be interrupted.

-- Kostya


--
Kostya Vasilyev -- http://kmansoft.wordpress.com

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to