Alireza
Alireza

Reputation: 209

Keep the screen on in Trusted Web Activity

I want to keep screen on while show trusted tabs. I was override the WebViewFallbackActivity class and inject this code but it's not working:

PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
PowerManager.WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WakelockTag");
wakeLock.acquire(10 * 60 * 1000L);

is there any solution to do this? Thanks.

Upvotes: 0

Views: 45

Answers (1)

andreban
andreban

Reputation: 4976

There is a solution for this!

You need to use the web WakeLock API instead. I've used it in https://doom-fire.com/, and you can keep the screen on by clicking on the padlock icon. You can check the code my implementation here.

Upvotes: 0

Related Questions