Android KeyguardManager requestDismissKeyguard is inconsistent

25 views Asked by At

As the title says, requestDismissKeyguard doesn't always work. It is flaky and works around 75% of the time. I have the below code written to dismiss the keyguard. 75% of the time it works and displays the activity that I created and 25% of the time is displays fingerprint/pattern/pin on top of my activity. Please help me out in figuring out if I missed something

class CallActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.O) {
            val keyguardManager = getSystemService(KEYGUARD_SERVICE) as KeyguardManager
            keyguardManager.requestDismissKeyguard(this, null)
            setShowWhenLocked(true)
            setTurnScreenOn(true)
        } else {
            window.addFlags(FLAG_SHOW_WHEN_LOCKED or FLAG_DISMISS_KEYGUARD or FLAG_TURN_SCREEN_ON)
        }
        setContentView(...)
    }
}
0

There are 0 answers