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();
This should be enough for your needs.
source share