Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google Place Picker未在某些手机上启动_Android_Google Places Api - Fatal编程技术网

Android Google Place Picker未在某些手机上启动

Android Google Place Picker未在某些手机上启动,android,google-places-api,Android,Google Places Api,我们正面临着谷歌Place Picker的一个问题,即它没有在一部特定的手机上启动(运行Android 6.0的MI Note 4),并引发了一个异常对话框,“不幸的是,谷歌Play服务…” 1) 代码在我们所有的测试手机上都起作用,除了这款手机外,大约有20种不同的型号,从姜饼到牛轧糖。因此,权限和密钥似乎没有问题。com.google.android.geo.API_密钥正确放置在应用程序部分 2) 这个问题只在这款手机上发生。手机上安装了Google play服务,呼叫GooglePlay

我们正面临着谷歌Place Picker的一个问题,即它没有在一部特定的手机上启动(运行Android 6.0的MI Note 4),并引发了一个异常对话框,“不幸的是,谷歌Play服务…”

1) 代码在我们所有的测试手机上都起作用,除了这款手机外,大约有20种不同的型号,从姜饼到牛轧糖。因此,权限和密钥似乎没有问题。com.google.android.geo.API_密钥正确放置在应用程序部分

2) 这个问题只在这款手机上发生。手机上安装了Google play服务,呼叫GooglePlayServicesUtil.isGooglePlayServicesAvailable将返回ConnectionResult.SUCCESS,这是我们在启动place picker之前检查的结果

3) 此外,这款手机还有play store,谷歌地图运行良好,这进一步证实了play服务的有效性

4) 我们甚至尝试将google play API降级到10.0.1和9.2.0,只是为了找到原因,但行为是一样的

下面是代码,这是一个标准的地点选择器代码

try {
     PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder();
     Intent intent = builder.build(this);
     startActivityForResult(intent, PLACE_PICKER_REQUEST);
 } catch (GooglePlayServicesRepairableException e) {
     GooglePlayServicesUtil
                    .getErrorDialog(e.getConnectionStatusCode(), this, 0);
 } catch (GooglePlayServicesNotAvailableException e) {
       Toast.makeText(this, "Google Play Services is not available.", Toast.LENGTH_LONG).show();
 } catch (Exception e) {
       Toast.makeText(this, "Google Play Services exception.", Toast.LENGTH_LONG).show();
 }

你知道哪里出了问题吗?

这个问题是由谷歌服务引起的。谷歌服务需要更新。所以,在打开应用程序或位置选择器之前,只需进行检查

if (googlePlayApiStatus == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED)
If返回true。向用户显示一个对话框以更新Google服务,并将下面的代码粘贴到Google play store以更新服务

final String appPackageName = "com.google.android.gms";
try {
/*IT WILL OPEN IN GOOGLE PLAY STORE*/
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
}
catch (android.content.ActivityNotFoundException anfe) {
/*IF GOOGLE PLAY STORE APP NOT FOUND IN DEVICE IT WILL OPEN IN WEB BROWSER*/
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + appPackageName)));
}

就这样

在logcat中是否有您可以发布的异常记录?