为了使用 GCM(Google Cloud Messaging),我需要在我的应用程序中实现 Google Play 服务库。在我的 Galaxy S2 (Android 4.1.2) 上一切正常,但在我的 HTC (Android 2.2.2) 上我无法更新 Google Play 服务。

在创建应用程序时 (onCreate),我检查是否安装了 Google Play 服务或是否需要更新:

public static boolean isGooglePlayServiceEnabled(Context context)
{
    return GooglePlayServicesUtil.isGooglePlayServicesAvailable(context) == ConnectionResult.SUCCESS ? true : false;
}

在我的 Activity 中:

onCreate(Bundle savedInstance)
{
    // Some code....
    if (!isGooglePlayInstalled(this))
    {
        int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(instance)
        if (errorCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED)
        {
            // Alert Dialog and prompt user to update App
            startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=com.google.android.gms")));
        }
    }
}

用户被重定向到电子市场以更新 Google Play 服务。但是当他到达时,没有“更新”按钮!它只有 2 个按钮:“打开”和“卸载”!

我该怎么办?

更新

我刚刚发现 Google 放弃了对 Android <= 8 (2.2.2) 的支持。

With over 97% of devices now running Android 2.3 (Gingerbread) or newer platform versions, we’re dropping support for Froyo from this release of the Google Play services SDK in order to make it possible to offer more powerful APIs in the future. That means you will not be able to utilize these new APIs on devices running Android 2.2 (Froyo).