pewaru-333 / HomeMedkit-App

Приложение, предназначенное для удобного хранения и управления вашими лекарствами.
GNU General Public License v3.0
39 stars 5 forks source link

Intake notification full screen intent doesn't work on some devices on > API 29 #43

Open pewaru-333 opened 1 month ago

pewaru-333 commented 1 month ago

Works on <= API 29 with adding to manifest:

<activity
            android:name=".IntakeDialogActivity"
            android:showForAllUsers="true"
            android:showWhenLocked="true"
            android:turnScreenOn="true" />

Searched through another apps, added this code — no success:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) { // API 27
            setTurnScreenOn(true)
            setShowWhenLocked(true)

            with(getSystemService(KEYGUARD_SERVICE) as KeyguardManager) {
                requestDismissKeyguard(this, null)
            }

            window.addFlags(
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED // deprecated
                        or WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD // deprecated
                        or WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
                        or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON // deprecated
                        or WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
            )
        }
pewaru-333 commented 3 days ago

This

android:showForAllUsers="true" 
android:showWhenLocked="true"
android:turnScreenOn="true"

is equals to

setTurnScreenOn(true)
setShowWhenLocked(true)

This just turns on screen immediately with lock (fingerprint/picture/pin), no reason to use it:

with(getSystemService(KEYGUARD_SERVICE) as KeyguardManager) {
      requestDismissKeyguard(this, null)
}

Need to use non-deprecated window flags:

window.addFlags(
      WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
      WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
)
pewaru-333 commented 3 days ago

On some devices fullscreen notification doesn't work, if schedule it before some time (< 5 min?).

If screen is on, no full screen, just pop up notification.