必须条件
如测试Google登录的条件:
- 手机具备翻墙能力
- 手机为Google手机或者安装Google Play service(各大应用市场搜索谷歌安装器)
- 应用签名配置正确
- google-services.json为最新并放置在module目录下
引入Google Play Service
参考:https://developers.google.com/android/guides/setup
配置AndroidManifest
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<resources>
<!-- Android-Sdk\extras\google\m2repository\com\google\android\gms\play-services -->
<integer name="google_play_services_version">12451000</integer>
</resources>
判断Google Play Service是否可用
public static boolean isGooglePlayServicesAvailable(Activity activity) {
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
Integer resultCode = googleApiAvailability.isGooglePlayServicesAvailable(activity);
if (resultCode != ConnectionResult.SUCCESS) {
Dialog dialog = googleApiAvailability.getErrorDialog(activity, resultCode, 0);
if (dialog != null) {
dialog.show();
}
return false;
}
return true;
}




