拨开荷叶行,寻梦已然成。仙女莲花里,翩翩白鹭情。
IMG-LOGO
主页 文章列表 以编程方式打开Android凭据设定

以编程方式打开Android凭据设定

白鹭 - 2022-03-08 2030 0 1

要显示敏感资料,用户可以在我的应用中启用身份验证。我正在使用以编程方式打开 Android 凭据设定

您可以从此处的设定到达那里:

以编程方式打开 Android 凭据设定

我正在寻找的是这样的:在这里,我们将用户导航到其他一些 android 设定。

Intent intent2 = new Intent();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  intent2.setAction(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
  intent2.putExtra(android.provider.Settings.EXTRA_APP_PACKAGE, getPackageName());
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
  intent2.setAction(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
  intent2.putExtra("app_package", getPackageName());
  intent2.putExtra("app_uid", getApplicationInfo().uid);
} else {
  intent2.setAction(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
  intent2.addCategory(Intent.CATEGORY_DEFAULT);
  intent2.setData(Uri.parse("package:"   getPackageName()));
}
startActivity(intent2);

uj5u.com热心网友回复:

刚刚想通了。

有 3 个可行的选项可供使用:Settings.ACTION_BIOMETRIC_ENROLL、Settings.ACTION_FINGERPRINT_ENROLL 和 Settings.ACTION_SECURITY_SETTINGS。

我使用的最终实作是:

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
    activity.startActivity(new Intent(Settings.ACTION_BIOMETRIC_ENROLL));
}
else {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
        activity.startActivity(new Intent(Settings.ACTION_FINGERPRINT_ENROLL));
    }
    else {
        activity.startActivity(new Intent(Settings.ACTION_SECURITY_SETTINGS));
    }
}

Settings.ACTION_FINGERPRINT_ENROLL 打开这个:选择备份锁屏方法并设定选择的方法后,设备会要求您注册指纹。 以编程方式打开 Android 凭据设定

Settings.ACTION_SECURITY_SETTINGS 打开这个: 以编程方式打开 Android 凭据设定

由于缺少高于 Android Build "R" 的设备,我无法测验 ACTION_BIOMETRIC_ENROLL,但我认为它类似于 ACTION_FINGERPRINT_ENROLL。

如果您想查看打开 android 设定的选项。您可以在 Android Studio 中的任何 Settings.XXX(ACTION_SECURITY_SETTINGS、ACTION_FINGERPRINT_ENROLL、...)上使用“CTRL” “鼠标单击”。然后你会看到“..\android\platforms\android-31\android.jar!\android\provider\Settings.class” 以编程方式打开 Android 凭据设定

如果您难以确定使用“Build.VERSION_CODES.P”描述的 API 版本,您还可以在构建版本(P、O、...)上单击“CTRL” “Mose Click”。然后你会看到这个: 以编程方式打开 Android 凭据设定

标签:

0 评论

发表评论

您的电子邮件地址不会被公开。 必填的字段已做标记 *