BiometricPrompt 提示未本地化

Ani*_*POS 6 android translation android-biometric-prompt

问题

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

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

在此处输入图片说明

环境

  • 使用的组件:androidx.biometric.BiometricPrompt
  • 使用的版本:1.0.0.0-alpha04
  • 设备/Android 版本转载于:模拟器 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)
    }
Run Code Online (Sandbox Code Playgroud)

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
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

Com*_*are 2

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

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