为了使用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;
}
Run Code Online (Sandbox Code Playgroud)
在我的活动中:
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")));
}
}
}
Run Code Online (Sandbox Code Playgroud)
用户被重定向到市场以更新Google Play服务.但是当他到达时,没有"更新"按钮!它只有2个按钮:"打开"和"卸载"!
我该怎么办?
UPDATE
我刚刚发现谷歌放弃了对Android <= 8(2.2.2)的支持.
现在有超过97%的设备运行Android 2.3(Gingerbread)或更新的平台版本,我们将从此版本的Google Play服务SDK中删除对Froyo的支持,以便将来能够提供更强大的API.这意味着您将无法在运行Android 2.2(Froyo)的设备上使用这些新API.
| 归档时间: |
|
| 查看次数: |
5913 次 |
| 最近记录: |