AuxOne wrote:
> For the WiFi lock I'm acquiring and releasing two locks now. Is that
> about right?
> 
> My WiFi lock looks like:
> 
> PowerManager mgr =
> (PowerManager)context.getSystemService(Context.WIFI_SERVICE);
> lockWifi = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
> LOCK_NAME_WIFI);
> lockWifi.setReferenceCounted(true);

That looks strange.

-- WifiLock is managed by WifiManager, which is not a PowerManager.

-- WifiManager has a createWifiLock() method to create the WifiLock, not
a newWakeLock() method

Also, I'm not sure this is necessarily going to work if you are locking
and unlocking at the time you are doing the WakeLocks. If your goal is
for WiFi to be available immediately upon the alarm, you will need to
use a WifiLock to keep WiFi active back when you schedule the alarm. To
quote from the WifiLock documentation:

"Normally the Wi-Fi radio may turn off when the user has not used the
device in a while. Acquiring a WifiLock will keep the radio on until the
lock is released. Multiple applications may hold WifiLocks, and the
radio will only be allowed to turn off when no WifiLocks are held in any
application."

If this is something that's supposed to be going on 24x7, since keeping
the WiFi radio on all that time will drain the battery pretty good, I
think you're more going to need to just hang tight in your
doWakefulWork() until WiFi connectivity is restored.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in NYC: 10-11 April 2010: http://guruloft.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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to