开发者

turn wifi on/off when phone screen lock(sleep)

Heloo all im new to 开发者_运维知识库android and im trying to create an application that turn the wifi off when the screen lock and enable the wifi every spacific time to fetch data and turn it off again while the phone in lock screen

i know how to 1)set the Timer 2)how to enable Wifi 3)disable Wifi

but i need to know how to listen to the lock screen event so when the screen locked my code will start.

any help plzz?


To detect screen wake, set a BroadcastRecever ACTION_SCREEN_ON. To detect screen unlock, use ACTION_USER_PRESENT.

  1. Use AlarmManager if you need your code to be run at scheduled intervals.
  2. Use WifiManager. Permissions are needed.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜