如何检查Play Service是否安装了Play Service?

时间:2016-10-17 10:33:19

标签: android firebase

我知道如何使用GoogleApiAvailability(GCM)进行检查。但FireBase核心库不支持此功能。

我的依赖关系是:

compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.google.firebase:firebase-core:9.6.1'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.android.support:support-v4:24.2.1'

2 个答案:

答案 0 :(得分:1)

我相信你正在寻找的是:

compile 'com.google.android.gms:play-services-auth:9.6.1'

答案 1 :(得分:-1)

也许有点晚了:)但我可以建议使用以下功能来检查Google Play服务的可用性:

private boolean checkPlayServices() {
    GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
    int resultCode = apiAvailability.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (apiAvailability.isUserResolvableError(resultCode)) {
            apiAvailability.getErrorDialog(this, resultCode,
                    PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.i(LOG_TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}