如何让我的apk中的谷歌播放

时间:2015-02-04 18:56:43

标签: android

我的安卓apk正在使用最新的谷歌播放服务。有些手机没有更新。所以我想在我的项目中制作最新的游戏apk,还有一种检查最新的谷歌游戏服务的方法是否可用? 如果没有那么我想要一些方法,以便用户可以安装它所以我认为我可以在我的应用程序中使用apk或者有没有其他方法让用户安装最新的播放服务?

1 个答案:

答案 0 :(得分:0)

将此信息包含在Manifest

<application>
<meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
...

并且在代码中放入了检查播放服务的方法:

protected boolean checkPlayServices() {
    final int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity());
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity(),
                    PLAY_SERVICES_RESOLUTION_REQUEST);
            if (dialog != null) {
                dialog.show();
                dialog.setOnDismissListener(new OnDismissListener() {
                    public void onDismiss(DialogInterface dialog) {
                        if (ConnectionResult.SERVICE_INVALID == resultCode) activity().finish();
                    }
                });
                return false;
            }
        }
        new CSAlertDialog(this).show("Google Play Services Error",
                "This device is not supported for required Goole Play Services", "OK", new Call() {
                    public void onCall(Object value) {
                        activity().finish();
                    }
                });
        return false;
    }
    return true;
}

这是版本检查:

int version = getPackageManager().getPackageInfo("com.google.android.gms", 0 ).versionCode;
相关问题