I'm programming an Android device for use in an industrial environment 
where it needs to stay in touch with the server even when the screen "goes 
to sleep". I thought I did all the right stuff but when the screen goes out 
it still sends a "Fin" to the server (confirmed on a network data packet 
sniffer).

I know that to do a WifiLock I must also do a WakeLock, so, in my onCreate 
I do . . . 

> private PowerManager.WakeLock wakelock;private WifiManager.WifiLock wifilock;
>
> . . . 
>
>     PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
>     wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "CPUOnly");
>     wakelock.acquire();
>     WifiManager wifiManager = (WifiManager) 
> getSystemService(Context.WIFI_SERVICE);
>     wifilock = wifiManager.createWifiLock(WifiManager.WIFI_MODE_FULL, 
> "WifiLock");
>     wifilock.acquire();
>
>
I read on the web that this doesn't work on some devices and you have to 
leave the screen on dim, so I replaced the line above with 

     wakelock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, 
> "CPUOnly");
>

That "worked" in the sense that WiFi stayed on, but at the expense of 
leaving the screen on dimly.   Is there any workaround to this so the 
screen can go off but WiFi stay on?

ALSO - this is on an Android 2.36 device, but the Android documentation  
says that as of API 17 SCREEN_DIM_WAKE_LOCK is deprecated and we're 
supposed to use FLAG_KEEP_SCREEN_ON, but that leaves the display on at *full 
brightness*!   So what are we supposed to do then?

Thanks in advance!

 

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to