最近,我的一些用户开始报告搜索图标已从 PlacePicker UI 小部件中消失。我能够将问题隔离到更新到 Google Play 服务 9.0.83。有没有人找到解决方法来重新找回搜索图标?
更新:我还注意到 PlacePicker.IntentBuilder 类的setLatLngBounds()方法在更新到 9.0.83 后不再正常工作。它将地图的中心定位在非洲海岸外的海洋中 0 纬度、0 度长。只要我不调用 setLatLngBounds(),PlacePicker 就会以我当前的位置为中心。
更新:我有一个想法,但我需要大家的帮助。根据来自该网站apkmirror.com的信息, 有基于 CPU 和屏幕 DPI 的 9.0.83 的子版本。在应用程序管理器中,选择 Google Play Services,subversion 应该在版本旁边的括号中,我的是440-121911109,如果您有同样的问题,请在评论中发表您的。也许我们可以找到一个共同点。
static final int PPR = 41;
private GoogleApiClient googleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.place_picker_activity);
googleApiClient = new GoogleApiClient
.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.enableAutoManage(this, this)
.build();
Button btnLaunch = (Button) findViewById(R.id.buttonLaunch);
btnLaunch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (googleApiClient.isConnected()) {
try {
PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
startActivityForResult(builder.build(PlacePickerActivity.this), PPR);
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
}
} else {
Toast.makeText(getApplicationContext(),"Google api not connected yet", Toast.LENGTH_SHORT).show();
}
}
});
}
@Override
protected void onStart() {
super.onStart();
googleApiClient.connect();
}
@Override
protected void onStop() {
super.onStop();
if (googleApiClient.isConnected()) {
googleApiClient.disconnect();
}
}
@Override
public void onConnected(Bundle connectionHint) { }
@Override
public void onConnectionFailed(ConnectionResult result) {
Toast.makeText(getApplicationContext(), "Connection failed: " + result.getErrorCode(), Toast.LENGTH_LONG).show();
}
@Override
public void onConnectionSuspended(int cause) {
Toast.makeText(getApplicationContext(), "Connection suspended",Toast.LENGTH_LONG).show();
googleApiClient.connect();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PPR) {
if (resultCode == RESULT_OK) {
Place place = PlacePicker.getPlace(this, data);
Toast.makeText(this, ""+place.getName(), Toast.LENGTH_LONG).show();
}
}
}