android– 是否可以询问用户是否要更新Google Play服务?

android– 是否可以询问用户是否要更新Google Play服务?,第1张

概述在他们为谷歌播放服务提供的示例中,他们处理可能的版本更新,如下所示:intresultCode=GooglePlayServicesUtil.isGooglePlayServicesAvailable(from);if(resultCode!=ConnectionResult.SUCCESS){if(GooglePlayServicesUtil.isUserRecoverableError(r

在他们为谷歌播放服务提供的示例中,他们处理可能的版本更新,如下所示:

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(from);        if (resultCode != ConnectionResult.SUCCESS) {            if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {                GooglePlayServicesUtil.getErrorDialog(resultCode, context,                        PLAY_SERVICES_RESolUTION_REQUEST).show();            } else {                error(TAG, "this device is not supported");            }

这会产生类似的消息

“Your application won’t work if you don’t update Google Services”.

对于我的应用程序,这个语句太强大,因为我只使用服务来提供一些oprional功能.

我可以用自己的方式替换GooglePlayServicesUtil.getErrorDialog()对话框吗?

理想情况下,我希望有类似的东西

“Google Services update is desirable. Yes/No”

解决方法:

你可以这样做:

int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(from);            if (resultCode != ConnectionResult.SUCCESS) {            // show your own AlertDialog for example:            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());            // set the message            builder.setMessage("This app use Google play services only for optional features")            .setTitle("Do you want to update?"); // set a Title            builder.setPositivebutton(R.string.ok, new DialogInterface.OnClickListener() {            public voID onClick(DialogInterface dialog, int ID) {                    // User clicked OK button                    final String appPackagename = "com.Google.androID.gms";                    try {                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?ID=" + appPackagename)));                    }catch (androID.content.ActivityNotFoundException anfe) {                        startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.Google.com/store/apps/details?ID=" + appPackagename)));                    }            }       });            builder.setNegativebutton(R.string.cancel, new DialogInterface.OnClickListener() {            public voID onClick(DialogInterface dialog, int ID) {               // User cancelled the dialog           }       });    AlertDialog dialog = builder.create();}
总结

以上是内存溢出为你收集整理的android – 是否可以询问用户是否要更新Google Play服务?全部内容,希望文章能够帮你解决android – 是否可以询问用户是否要更新Google Play服务?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1113519.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存