2017-05-12 43 views
0

我们正面临Google Place Picker的一个问题,即它并未在一台特定的手机上启动(MI Note 4运行Android 6.0),并引发异常对话,“不幸的是,Google Play服务。 ..“。Google Place Picker不会在某些电话上启动

1)代码正在使用我们所有的测试手机,约20款不同的型号从姜饼到牛轧糖除了这款手机。因此,许可和密钥似乎不是问题。 com.google.android.geo.API_KEY已正确放置在应用程序部分。

2)这个问题特别发生在这款手机上。谷歌播放服务安装在手机上,并呼吁GooglePlayServicesUtil.isGooglePlayServicesAvailable返回ConnectionResult.SUCCESS如预期的那样,我们在启动地方选择器之前检查。

3)另外,手机有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(); 
} 

任何想法什么可能是错的?

+0

logcat中是否有任何异常记录可以发布? – AndrewR

回答

0

由于Google服务而发生此问题。 Google服务需要更新。因此,只需在打开应用或放置选取器之前进行检查即可。

if (googlePlayApiStatus == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) 

如果返回true。向用户显示一个对话框,以更新Google服务并粘贴以下代码,以便用户访问Google Play商店以更新服务。

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))); 
} 

就是这样!

相关问题