Here i mentioned the code for waking up the screen. i want the code is listen still the app is closed and the cpu is cleared and user can click the power button when ever my screen is unlock the app is sync like whatsapp.
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
wl = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "whatever");
super.onCreate(savedInstanceState);
wl.acquire();
FULL_WAKE_LOCK is already deprecated and it's better to use the PARTIAL_WAKE_LOCK. This is the standard way to do this,
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
Wakelock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
"MyWakelockTag");
wakeLock.acquire();
For more way of implementation kindly visit the official link,
https://developer.android.com/training/scheduling/wakelock.html