I'm trying to lock the screen of my tablet after being unplugged for 15 minutes using a broadcast receiver that detects if the tablet is plugged to an alimentation or not.
This broadcast receiver is placed into a service.
If the power is plugged, a Toast will display "Power Connected" , if unplugged, a Toast will display "Power Disconnected". And it works from any activity of my application. (That part is running well)
I'm blocking on "how to lock/turn off screen the tablet when it happens".
I'd also need to unlock that tablet when the power is plugged. I removed all lockscreens from the settings, there's no issue with slide to unlock or enter the pin or pattern.