判断手机是否支持google play服务

android开发报错

或者提示手机不支持google服务或者google map 服务等功能的解决办法:


简介:   

 在针对需要google 服务的软件开发中,国内开发者经常会出现手机不支持google play 服务的提示,不支持Google Play服务是谷歌推出国内市场后经常出现的问题。判断设备是否支持google service 服务是构建谷歌更好应用的一个框架支持,国外的google map, google的一些应用都需要依托于这个google服务,那么我们会连Oncreate方法都进不去,国内的手机,例如小米是不支持google服务的,它作为官方应用程序商店Android的操作系统,允许用户浏览和发展了与下载应用程序的Android SDK, 如何判断设备是否支持google 服务,作为针对开发国内外用户的使用的APP的时候极为重要

方法

如果在build.gradle中加了

compile'com.google.android.gms:play-services:9.6.1'
加入了这一整个 service 是不容易判断的,因为加入这个方法,里面有一个自启动类,会让程序启动,但是我们手机又又不支持google service 服务,我们针对于具体的业务,来对google 的service添加引入,例如我们只需要引入google map api 和 google place api,例如

dependencies {
 
compile 'com.google.android.gms:play-services-places:9.6.1'
compile 'com.google.android.gms:play-services-maps:9.6.1'
}
而不是
compile 'com.google.android.gms:play-services:9.6.1'

然后在程序中加判断

boolean googleserviceFlag = true;
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
intresultCode = googleApiAvailability.isGooglePlayServicesAvailable(this);
if(resultCode != ConnectionResult.SUCCESS) {
if(googleApiAvailability.isUserResolvableError(resultCode)) {
googleApiAvailability.getErrorDialog(this, resultCode, 2404).show();
}
googleserviceFlag=false;
}
if(googleserviceFlag==false){
说明不支持google服务

}

可参考:http://blog.csdn.net/t1dmzks/article/details/52918472

google play service最新版本,基于firebase的sdk,9.2.0.包含了 全部需要的jar,另外还有aar版本 play-services-ads-9.2.0.jar play-services-analytics-9.2.0.jar play-services-analytics-impl-9.2.0.jar play-services-appindexing-9.2.0.jar play-services-appinvite-9.2.0.jar play-services-appstate-8.4.0.jar play-services-auth-9.2.0.jar play-services-auth-base-9.2.0.jar play-services-base-9.2.0.jar play-services-basement-9.2.0.jar play-services-cast-9.2.0.jar play-services-cast-framework-9.2.0.jar play-services-clearcut-9.2.0.jar play-services-contextmanager-9.2.0.jar play-services-drive-9.2.0.jar play-services-fitness-9.2.0.jar play-services-games-9.2.0.jar play-services-gass-9.2.0.jar play-services-gcm-9.2.0.jar play-services-identity-9.2.0.jar play-services-iid-9.2.0.jar play-services-location-9.2.0.jar play-services-maps-9.2.0.jar play-services-measurement-8.4.0.jar play-services-nearby-9.2.0.jar play-services-panorama-9.2.0.jar play-services-places-9.2.0.jar play-services-plus-9.2.0.jar play-services-safetynet-9.2.0.jar play-services-tagmanager-9.2.0.jar play-services-tagmanager-api-9.2.0.jar play-services-tasks-9.2.0.jar play-services-vision-9.2.0.jar play-services-wallet-9.2.0.jar play-services-wearable-9.2.0.jar play-services-ads-lite-9.2.0.jar firebase-analytics-9.2.0.jar firebase-analytics-impl-9.2.0.jar firebase-auth-9.2.0.jar firebase-auth-common-9.2.0.jar firebase-auth-module-9.2.0.jar firebase-common-9.2.0.jar firebase-config-9.2.0.jar firebase-crash-9.2.0.jar firebase-database-9.2.0.jar firebase-database-connection-9.2.0.jar firebase-iid-9.2.0.jar firebase-messaging-9.2.0.jar firebase-storage-9.2.0.jar firebase-storage-common-9.2.0.jar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-每天进步一点点-

你的鼓励是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值