【问题标题】:HERE Maps: Language for RouteOptions after setLocale in Android N stays system languageHERE 地图:Android N 中 setLocale 后 RouteOptions 的语言保持系统语言
【发布时间】:2019-05-31 16:30:39
【问题描述】:

我使用的是 Here Maps Android SDK Premium,版本 3.11.2.82。我在使用 Here maps sdk 时将语言设置为我的 RouteOptions 对象时遇到问题。当我的系统语言是英语并且我更改了应用程序语言时,从 Android N 开始,路线结果中的语言不会更新,并且路线项目以英语显示。以下是我在尝试查找路线时设置 RouteOptions 的方式:

val routeOptions = RouteOptions()
routeOptions.locale = localeProvider.currentLocale
routeOptions.transportMode = RouteOptions.TransportMode.TRUCK
routeOptions.routeType = RouteOptions.Type.FASTEST
routeOptions.setTruckLength(12.192f)
    .setTruckWidth(2.5908f)
    .setTruckHeight(3.9624f)
    .setTruckLimitedWeight(36.28739f).truckWeightPerAxle = 26.589585f
routePlan.routeOptions = routeOptions
router.calculateRoute(routePlan, RouteListener(destinationSearchResult, routePlan))

区域设置肯定不同(类似于西班牙语区域设置(“es”)),我的设备设置为英语。

我通过设置覆盖语言

val locale = Locale("es")
Locale.setDefault(locale)
LocaleList.setDefault(LocaleList(locale))

我还在我的基本活动中覆盖这些:

@Override
protected void attachBaseContext(Context base) {
    super.attachBaseContext(updateBaseContextLocale(base));
}

@Override
public void applyOverrideConfiguration(Configuration overrideConfiguration) {
    super.applyOverrideConfiguration(getUserLanguageConfiguration(overrideConfiguration));
}

我将带有更新语言环境的新配置设置为上下文。最后,我在我的基础应用程序中覆盖了配置更改:

@Override
public void onConfigurationChanged(Configuration newConfiguration) {
    super.onConfigurationChanged(getUserLanguageConfiguration(newConfiguration));
....
}

我还更新了新配置中的语言环境并将其设置为基本上下文。

RouteOptions.setLocale(..) 在 Android M 中运行良好,但在 Android N 中却不行。我的应用程序的其余部分使用正确的语言,所以这是一个错误还是我在监督什么?还有其他方法可以为 Here Maps 库设置语言/区域设置吗?

【问题讨论】:

  • 感谢您报告此问题。我们将寻找根本原因,稍后再与您联系。
  • @HEREDeveloperSupport 关于这个问题的任何更新? :)
  • 什么类型的对象 localeProvider 用于获取路由设置的区域设置? routeOptions.locale = localeProvider.currentLocale 更改应用的区域设置后localeProvider.currentLocale属性是否有预期值?

标签: android here-api


【解决方案1】:

请使用我们最新的 HERE Android 移动 SDK 版本 3.14。通过RouteOptions 更改区域设置应该按照我们文档中的说明进行:

Sets the language for route request using a locale.

https://developer.here.com/documentation/android-premium/api_reference_java/com/here/android/mpa/routing/RouteOptions.html#setLocale-java.util.Locale-

【讨论】:

  • 我试试,如果不行我会告诉你的!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多