I am creating a car computer with a tablet (Asus MemoPad ME572C). I have an arduino connected with the tablet through an usb to serial adapter. Now i need to be able to turn the screen on from standby.
What i tried is putting this in the oncreate of an activity
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
);
This is working but if i leave the tablet for a minute or so turned into standby, i can't wake it anymore. It looks like the tablet has stopped my service or just doesn't listen on the serial port.
I don't know how to debug this or solve it. Hope you can help.
PS: sorry my english isn't very good.
Note that for the method your using (WindowManager.LayoutParams flags) your activity needs to be fullscreen.
If that doesn't work try this answer. It's a depreciated method, so you don't want to keep it long-term.
Quoting from @Yar:
If that doesn't work you'll need to investigate whether the service is being shut down. You should be able to prevent that happening by calling
startForeground()
on your service. See the documentation for explanation and sample code.