如何以编程方式使用密码/图案解锁手机的锁屏? (Android Studio)

我想知道当前如何通过代码解锁手机,我已经看到很多类似的问题,但在当前版本中均无作用,有什么解决方案吗?

我试过了

    private Window wind;
    @Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    /******block is needed to raise the application if the lock is*********/
    wind = this.getWindow();
    wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
    wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
    /* ^^^^^^^block is needed to raise the application if the lock is*/
}

and use KeyguardManager but still didn't work

评论