Android FULL_WAKE_LOCK is deprecated, but PARTIAL_WAKE_LOCK is not deprecated
Here I mentioned the code to wake up the screen. i want the code to listen, the app is closed and the cpu is cleared and the user can press the power button, when my screen is unlocked, the app syncs like whatsapp.
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "whatever");
super.onCreate(savedInstanceState);
wl.acquire();
+3
source to share
1 answer
FULL_WAKE_LOCK is already deprecated and it is better to use PARTIAL_WAKE_LOCK . This is the standard way to do it,
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
Wakelock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
wakeLock.acquire();
For more information on how to do this, kindly visit the official link.
https://developer.android.com/training/scheduling/wakelock.html
+4
source to share