生物识别身份验证从主要活动导航到背面,它不断促进生物识别身份验证

发布于 2025-01-20 03:12:21 字数 197 浏览 0 评论 0原文

我是Android开发的新手。当用户背部从另一个活动到主要活动时,我需要帮助,生物识别称为我只想在应用程序启动

  if (biomatricAvaliable()) {
        biometricPrompt.authenticate(promptInfo)
    }

上述代码在主要活动中仅一次执行它。

I am very new to android development. I need help when user back press from another activity to main activity the biometric is called I want to execute it only one time when the app start

  if (biomatricAvaliable()) {
        biometricPrompt.authenticate(promptInfo)
    }

the above code is in main activity it is called every time when user goes to main Activity.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卷耳 2025-01-27 03:12:21

您需要做的第一件事是确定何时要进行身份验证。您是否只想在应用程序启动时进行验证(请记住,如果应用程序在Android上简短背景,则可以在后台重新启动,因此这种情况可能比您喜欢的更频繁)?每X分钟?他们上次使用该应用程序后的每X分钟?这些都改变了场景。我假设您不希望他们对其进行身份验证并永远完成,这是毫无意义的。

决定后,您需要测试该条件,并将其添加到If If语句中。例如,如果您需要每隔几分钟,则将其写入上次对共享首选项进行身份验证,在此处检查该共享偏好,并在不存在的情况下运行身份验证,或者在X分钟前超过X。刷新与共享偏好相似,但是您会更新Onpause或每当在应用程序中做一些重要的事情时。但是,主要的事情是决定什么应该和不应该首先触发身份验证。

The first thing you need to do is decide when you want to authenticate. Do you want to auth only when the app starts (remember that if the app is briefly backgrounded on Android it can be restarted in the background, so this may happen more frequently than you like)? Every X minutes? Every X minutes after they last use the app? These all change the scenario. I'm going to assume you don't want them to authenticate once and be done with it forever, that's kind of pointless.

Once you've decided that, you need to test for that condition and add it to your if statement there. For example, if you want it every few minutes, you'd write the last time they authenticated to shared preferences, check that shared preference here, and run authentication if it doesn't exist or if it was more than X minutes ago. With a refresh would be similar with shared preference, but you'd update the time in onPause or whenever they do something important in the app. But the main thing is deciding what should and shouldn't trigger authentication first.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文