Skip to content Skip to sidebar Skip to footer

Android Keep Screen On On Samsung Devices

I have a streaming app and I want to avoid that the screen turns off while streaming. It works on most of my devices but it doesn't on certain Samsung devices (Samsung Galaxy S21 U

Solution 1:

I incidentally found this: https://dontkillmyapp.com/samsung

UPDATE 2021: Despite Android team promise to enforce OEMs to be transparent about non-standard app killing, in Android 11 Samsung has introduced a new severe (default ON) restriction. Apps can no longer hold wake lock in foreground services. This breaks many use-cases, for instance health apps are now unable to gather sensoric data for their users. See details here and read below for workarounds.


Solution 2:

You can do that with this code below:

PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
        "MyApp::MyWakelockTag");
wakeLock.acquire();

More informations: Android Documentation


Post a Comment for "Android Keep Screen On On Samsung Devices"