Before marking this post as a \"duplicate\", I am writing this post because no other post holds the solution to the problem.
I am trying to turn off the device, then
As per Android API 28 and above you need to do the following to turn on the screen
setShowWhenLocked(true); setTurnScreenOn(true); KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); keyguardManager.requestDismissKeyguard(this, null);