以编程方式更改区域设置以影响Google的地方自动填充服务(Google Places API for Android)

时间:2017-02-07 20:57:24

标签: android localization locale google-places-api google-places

有没有办法以影响 Google广告自动填充服务的方式以编程方式更改Locale

我将描述我的情况:

我使用的设备带有英语 Locale。正如预期的那样,当我使用希伯来语搜索地方自动填充服务时,它会在希伯来语中以 LTR方向呈现可能的结果,当我按结果并从Place方法中的onPlaceSelected()对象中提取数据,返回的信息为英语

This is how it looks when I run the app and press the chosen location

这是使用地方自动填充服务的代码:

PlaceAutocompleteFragment placeAutocompleteFragment = (PlaceAutocompleteFragment)
    getFragmentManager().findFragmentById(R.id.place_autocomplete_fragment);

placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
    @Override
    public void onPlaceSelected(Place place) {
        nameString = place.getName().toString();
        addressString = place.getAddress().toString();
        phoneNumberString = place.getPhoneNumber().toString();
        LatLng latLng = place.getLatLng();
        latitudeDouble = latLng.latitude;
        longitudeDouble = latLng.longitude;

        nameEditText.setText(nameString);
        addressEditText.setText(addressString);
        phoneNumberText.setText(phoneNumberString);
        latitudeTextView.setText(latitudeDouble.toString());
        longitudeTextView.setText(longitudeDouble.toString());
    }

    @Override
    public void onError(Status status) {
        // TODO: Handle the error.
        Log.i(TAG, "ERROR MESSAGE: " + status);
    }
});

问题是,即使我成功更改了Locale Activity以编程方式通过以下方式仍然无法正常工作:

Locale locale = new Locale("iw");
Locale.setDefault(locale);
super.onCreate(savedInstanceState);
...

有没有办法解决这个问题?

0 个答案:

没有答案