• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Froyo 2.2 and Wifi

Hi,

By default, Wifi sleep policy is "Sleep on screen idle".

With this policy, is it possible for a Background Service at a later time to wake up Wifi using some API?

Am trying the following, but does not work:
When my Background Service wakes up, it calls "ConnectivityManager.getActiveNetworkInfo()" to get active network.
Since, the wireless is off on idle, I tried waking it up using "WifiManager.startScan" on a previously used Wifi connection.
But still dont get Wifi connectivity.

Any ideas?
I preferably do not want to change my sleep policy to "Never".

Thanks
Hemant
 
You're looking for the WifiLock in the Wifi Manager class. Take a look at this.
Looks like WifiLock works only if you have an Active Wifi Connection. Then when you acquire the lock, it ensures that Wifi will be active until the lock is released.

In my case, looking at something to activate the wifi from a background service (which wakes up periodically)
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones