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 Ultra, Samsung Galaxy S10 etc). What I tried so far:
Add this to the onCreate view of my activity
this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
Add the keepScreenOn on the root component of my layout xml
android:keepScreenOn="true"
Use Power manager to prevent the screen from turning off in my onCreate
PowerManager powerManager = (PowerManager) this.getSystemService(Context.POWER_SERVICE); this.wakeLock = powerManager.newWakeLock(PowerManager.FULL_WAKE_LOCK, "test."); this.wakeLock.acquire();
Doesn't matter what I do, Samsung screen lock will show up after a while and it will look like in the attached image below
Permissions like WAKE_LOCK are added in the Manifest of course. It seems so simple but I don't know how to avoid this. I constantly get complaints from users who are using my app on Samsung devices that the screen keeps turning off when they are using a gamepad for example and not actively touching the screen. How can this be avoided on Samsung devices? It seems works fine on all other Devices. I also checked a lot of stack overflow entries before and didn't find anything specific but maybe I missed something. Can anyone point me in the right direction?