How to save Android standby app?

The problem is that my application stops working in sleep mode. The user wants to take orders in sleep mode via a bluetooth scanner. Is there any class that keeps the phone in sleep mode, and in the background it takes orders or some suggestion to achieve this task or any example application?

+4
source share
1 answer

Running your application in sleep mode is not recommended unless you really need it. This is because it dramatically affects the life of the dough.

In your case, you need to purchase WakeLock . You can create a new instance of WakeLock using PowerManager.newWakeLock() .


Example from the documentation:

 PowerManager pm = (PowerManager)mContext.getSystemService( Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); wl.acquire(); // ... wl.release() 

This should be enough for your needs.

+7
source

All Articles