I tried a few things on an ICS device.
 
When the phone is in sleep mode, I use an AlarmManager to wake up.
During that alarm-manager handler, if I acquire a wifi-lock and a 
wakeup-lock.
 
Still, if I enable/disable wifi programmatically, it doesn't work.
 
But the moment I switch on the screen manually, it works fine.
Any ideas why?
 

On Friday, March 30, 2012 6:22:07 PM UTC+5:30, Kostya Vasilyev wrote:

>  
>
> 30.03.2012 16:31, Mark Murphy написал: 
>
> IMHO, the SwitchPreference where tapping on the preference **also**
> launches a nested PreferenceScreen is lousy UX. I keep forgetting
> there are options under the WiFi one, until I'm trying to connect to
> some new AP and then eventually stumble upon it. And, of course,
> buried inside of there are the advanced settings.
>
>  
> It's worse than that - not only is it necessary to enter the screen that 
> lists networks, it's also necessary to use the Menu (button or the famous 
> three little dots) and bring up "Advanced (Additional) settings"
>
>  FWIW, the Galaxy Nexus default seems to be always-on -- I toggled mine
> back to only-when-plugged-in.
>
>  
> Yes, the default seems to have changed starting with 2.3 (perhaps together 
> with better power management - keeping the WiFi hardware in some kind of 
> low-power mode... that's pure speculation on my part), but I wouldn't count 
> on all manufacturers being consistent with each other.
>
> And then, some users do discover the setting to change the policy.
>
>
>  > From an application's point of view, though, it's just same old> 
> ConnectivityManager.getActiveNetworkInfo - the connection is either there> 
> and it's WiFi, or it's not.
>
>  Well, the decision on whether to use a WifiLock would be based in part
> on WIFI_SLEEP_POLICY -- if WIFI_SLEEP_POLICY is
> WIFI_SLEEP_POLICY_NEVER, you do not need the WifiLock. That was the
> point behind your original post on this thread IIRC.
>
>  
> Checking this setting isn't necessary.
>
> If the WiFi chip is actually on (sleep policy "never" or "plugged in" and 
> the device is in fact plugged in), there will be a connection unless there 
> is nothing to connect to. In the latter case acquiring a WiFi lock is 
> pointless.
>
> If the sleep policy is "off when the screen is off", and the hardware 
> really is off, WifiManager.isWifiEnabled() will still return true, and 
> that's when you'll need to acquire a WiFi lock to set things in motion.
>
> I've only seen this fail on an HTC Hero with 2.1, but that's ancient 
> history. A Moto Milestone also with 2.1 behaves like more current devices.
>
> -- K
>
> 

-- 
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

Reply via email to