I am doing one application for that I need to put a android device to sleep mode. How to put a device to sleep mode and how to wake-up a device when it is in sleep mode.
Thanks in advance
How to put a device to sleep mode
You don't. You allow the device to fall asleep of its own accord, when the user is done working with it, based upon the user's preferences as set up in Settings.
how to wake-up a device when it is in sleep mode.
If it is supposed to wake up at a certain time, use AlarmManager
with a getBroadcast()
PendingIntent
. The device will stay awake long enough for your BroadcastReceiver
to be called with onReceive()
. Once onReceive()
returns, the device can fall back asleep. If your work is too long to do in onReceive()
, you will need to delegate that work to some other component (e.g., an IntentService
) and use a WakeLock
to keep the device awake long enough for you to complete the work and no longer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With