在创建android + googlemap时应检查手机是否有Google Play services APK

As described in the Google Play services introduction, Google Play delivers service updates for users on Android 2.2 through the Google Play Store app. However, updates might not reach all users immediately.

Important: Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK in your app before you access Google Play services features. For many apps, the best time to check is during the onResume() method of the main activity.

Here are four scenarios that describe the possible state of the Google Play services APK on a user's device:

  1. A recent version of the Google Play Store app is installed, and the most recent Google Play services APK has been downloaded.
  2. A recent version of the Google Play Store app is installed, but the most recent Google Play services APK hasnot been downloaded.
  3. An old version of the Google Play Store app, which does not proactively download Google Play services updates, is present.
  4. The Google Play services APK is missing or disabled on the device, which might happen if the user explicitly uninstalls or disables it.

Case 1 is the success scenario and is the most common. However, because the other scenarios can still happen, you must handle them every time your app connects to a Google Play service to ensure that the Google Play services APK is present, up-to-date, and enabled.

To help you, the Google Play services client library has utility methods to determine whether or not the Google Play services APK is recent enough to support the version of the client library you are using. If not, the client library sends users to the Google Play Store to download the recent version of the Google Play services APK.

Note: The Google Play services APK is not visible by searching the Google Play Store. The client library provides a deep link into the Google Play Store when it detects that the device has a missing or incompatible Google Play services APK.

It is up to you choose the appropriate place in your app to do the following steps to check for a valid Google Play services APK. For example, if Google Play services is required for your app, you might want to do it when your app first launches. On the other hand, if Google Play services is an optional part of your app, you can do these checks if the user navigates to that portion of your app:

  1. Query for the status of Google Play services on the device with the isGooglePlayServicesAvailable()method, which returns a result code.
  2. If the result code is SUCCESS, then the Google Play services APK is up-to-date, and you can proceed as normal.
  3. If the result code is SERVICE_MISSINGSERVICE_VERSION_UPDATE_REQUIRED, or SERVICE_DISABLED, then call getErrorDialog() to display an error message to the user, which allows the user to download the APK from the Google Play Store or enable it in the device's system settings.
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
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
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值