Neil,
That's pretty much how I test too, except my code lacks a check for
isConnected, only for null.
This is what I get in my app's log:
NetworkInfo: type: MOBILE[EDGE], state: CONNECTED/CONNECTED, reason:
apnSwitched, extra: internet.mts.ru, roaming: false, failover: false,
isAvailable: true
Two ideas:
- Check your phone settings, perhaps yours has some kind of sleep policy
for mobile data;
- Log the value you get by calling getActiveNetworkInfo into a file, and
examine later.
-- Kostya
05.02.2011 16:20, Neilz пишет:
Hi Kostya.
Yes, the alarm gets called... it's just my own call which stops it
doing it's task. For example:
if(isNetworkAvailable(mContext)){
// do stuff...
}
public static boolean isNetworkAvailable(Context context) {
ConnectivityManager connMgr = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = connMgr.getActiveNetworkInfo();
return(info != null&& info.isConnected());
}
So this call tells me the network isn't available when the phone's
asleep. I guess I'll have to try another way of testing for the
network?
On Feb 5, 1:07 pm, Kostya Vasilyev<[email protected]> wrote:
05.02.2011 15:40, Neilz пишет:
Ok, one problem with this alarm service.
I schedule it for some time in the morning, and when I get up and
check the phone, the alarm didn't get called, because it thinks
there's no network connection.
I'm sure the alarm did get called, as the AlarmManager service has
nothing to do with networking.
This is a call I make deliberately (I always check there's a
connection before making the server request)... but why does it think
there's no network when the phone is 'sleeping'? The connection is
still there...
Depends on what kind of network connectivity you expect.
In my tests (Moto Milestone), WiFi doesn't get enabled when the phone is
woken by an alarm, but the cellular data connection is available
immediately.
--
Kostya Vasilyev -- WiFi Manager + pretty widget --http://kmansoft.wordpress.com
--
Kostya Vasilyev -- WiFi Manager + pretty widget -- 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en