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
I have tried all above solution but none worked for me. so I googled and found below solutions. I tried and it worked.
https://www.tutorialspoint.com/how-to-turn-android-device-screen-on-and-off-programmatically
if there is any suggestion then please give