帐户套件:设置Android应用程序的默认语言

时间:2017-03-31 17:58:59

标签: android android-gradle account-kit

我尝试使用Account Kit为我的Android应用添加默认语言但没有成功。我现在不想要支持英语,但当设备使用英语作为系统语言时,帐户套件也会发生变化。

我关注文档,所以我在build.gralde文件中设置了resCong

defaultConfig {
    applicationId "fm.mumo.music"
    minSdkVersion 15
    targetSdkVersion 25
    versionCode 16
    versionName "0.3.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    multiDexEnabled = true
    resConfigs "pt-rBR"
    resValue "string", "facebook_app_id", "$alphaFacebookAppId"
    resValue "string", "account_kit_client_token", "$alphaAccountKitClientToken"
}

1 个答案:

答案 0 :(得分:1)

resConfigs "pt-rBR"位用于去除未在其中列出的所有语言环境。这不会取出默认语言,在这种情况下是英语。如果您尝试“替换”默认语言环境,则可以执行以下操作:

如果您知道不支持用户的区域设置,则可以在“活动”或“应用程序”中执行以下操作以“强制”区域设置。这将是“交换”默认语言环境的一种方式。

Configuration localeConfig = getResources().getConfiguration();
  localeConfig.locale = Locale.FRENCH;
  getResources().updateConfiguration(localeConfig, getResources().getDisplayMetrics());

但是,如果已知不支持Locale.getDefault(),则必须小心这样做,因此将显示AccountKit默认值(英语)。

相关问题