6

问题

我们正在更改应用程序内的区域设置,除了指纹对话框中的提示外,一切正常。无论我们设置什么语言,我们总是有英文提示:

  • 触摸指纹传感器
  • 未识别
  • ETC...

在此处输入图像描述

环境

  • 使用的组件:androidx.biometric.BiometricPrompt
  • 使用的版本:1.0.0.0-alpha04
  • 设备/Android 版本转载于:emulator API 28

如何设置语言环境:

    private fun setNewLocaleAndRestart(language: String) {
        LocaleManager(this).setNewLocale(language)

        //restarting app
        val i = Intent(this, SplashScreenActivity::class.java)
        startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK))
        finish()
        System.exit(0)
    }

class LocaleManager(val context: Context) {

    val sharedPreferenceManager = createSharedPreferenceManager(context)

    fun setLocale(): Context = updateResources()

    fun setNewLocale(language: String): Context {
        return updateResources(language)
    }


    private fun updateResources(l: String? = null): Context {

        val language = l ?: sharedPreferenceManager.language

        if (language.isBlank()) return context

        val locale = Locale(language)

        Locale.setDefault(locale)

        val res = context.resources
        val config = Configuration(res.configuration)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            config.setLocale(locale)
            return context.createConfigurationContext(config)
        } else @Suppress("DEPRECATION") {
            config.locale = locale
            res.updateConfiguration(config, res.displayMetrics)
            return context
        }

    }
}
4

4 回答 4

2

一切正常,除了指纹对话框中的提示

所有系统对话框都将使用用户为设备设置的语言。这包括生物识别系统对话框。

于 2019-05-08T18:38:50.240 回答
1

我刚刚实现了 BiometricManagerandroidx.biometric:biometric:1.0.1并且能够更改和本地化提示文本以及使用错误指纹时的文本。

你只需要在你的 strings.xml 中定义这些字符串来覆盖 API 上的那些:

fingerprint_not_recognized使用错误指纹时更改错误消息。这是在FingerprintHelperFragment.java中定义的

fingerprint_dialog_touch_sensor更改提示。这是在FingerprintDialogFragment.java中定义的

BiometricManager_TouchSensor_Message BiometricManager_WrongFingerprintUsed_Message

于 2020-06-13T00:55:29.250 回答
0

我也在经历这个implementation 'androidx.biometric:biometric:1.0.1@aar'。我将系统语言更改为英语以外的其他语言,但它仍然显示“触摸指纹传感器”。有没有人对此有解决方案或解释?

看起来Android 生物识别库似乎已经支持所有语言,但它似乎不起作用。我什至可以merger.xml在 Android 构建文件夹中看到生成的翻译。

在装有 Android 9/Oxygen 9.0.10 的 OnePlus 5T 上进行了测试。

于 2020-03-05T10:02:18.227 回答
0

它已在 BiometricPrompt 版本中修复androidx.biometric:biometric:1.0.0-alpha04。您只需要更改您的电话区域设置即可反映更改。

如果你有兴趣,这里是它的提交

于 2019-08-27T14:15:49.327 回答