我想通过锁定屏幕上的推送通知启动我的 Activity ,而无需更改锁定。

该 Activity 有任何特殊许可吗?

最佳答案

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1)
    {
        setShowWhenLocked(true);
        setTurnScreenOn(true);
        KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
        if(keyguardManager!=null)
            keyguardManager.requestDismissKeyguard(this, null);
    }
    else
    {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    }

关于android - Android,如何在锁定屏幕上启动 Activity ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35356848/

10-11 08:11