如何检查Google Play服务的版本?

97

在我的应用程序中,我需要检查用户设备中安装的Google Play服务版本号。这可行吗?如果可以,如何实现?

12个回答

0
使用以下函数来检查是否可以使用Google Play服务:
 private boolean checkGooglePlayServicesAvailable() {
    final int connectionStatusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (GooglePlayServicesUtil.isUserRecoverableError(connectionStatusCode)) {
        showGooglePlayServicesAvailabilityErrorDialog(connectionStatusCode);
        return false;
    }
    return true;
}

-4
int registeredVersion = prefs.getInt(PROPERTY_APP_VERSION, Integer.MIN_VALUE);
    int currentVersion = getAppVersion(context);
    if (registeredVersion != currentVersion) {
        Log.i(TAG, "App version changed.");
        return "";
    }

这不是一个解决方案。 - Stanley Ko

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接