为了使用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; }
在我的活动中:
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个按钮:“打开”和“卸载”!
我该怎么办?
UPDATE
我刚刚发现谷歌放弃了对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).
解决方法
您的设备没有最新版本的Google Play服务.如果没有可用的更新,PlayStore将仅提供您打开该应用程序.