谷歌Play服务的可选安装

4
我正在开发一款想要使用Google Cloud Messaging的Android应用程序。这需要使用Google Play服务。Android开发者网站介绍了如何检查Google Play服务是否可用,如果不可用,则使用错误代码传递给GooglePlayServicesUtil.getErrorDialog(),以显示本地化对话框,允许用户跳转到Play商店安装Google Play服务或在设置中启用它。
按照这种逻辑进行的初始测试 SERVICE_MISSING 条件会显示一个对话框,上面写着“此应用程序无法运行,因为您的手机缺少 Google Play 服务”。
然而,在我的情况下,Google Cloud Messaging(因此也是 Google Play Services)仅用于支持可选功能。说应用程序“无法运行”是不正确的。但是,这个文本来自GooglePlayServicesUtil。
我可以构建自己的对话框并选择自己的文本,而不是使用getErrorDialog()。但是,据我所知,Play服务的Play商店URL不是公开的。我还没有做过实验,但我能预见到类似的问题可能会出现在SERVICE_DISABLED路径上。
有人知道如何将应用程序特定的文本与GooglePlayServicesUtil的保密操作融合吗?

我真正希望的是,添加一个OnCancelListener会在对话框中添加一个新按钮,上面写着“不,谢谢”。 - withoutclass
1个回答

3

由于Google Play服务的资源驻留在一个库项目中,您应该能够在自己的应用程序中轻松地覆盖它们。您将在strings.xml文件中找到以下内容(以及其他字符串):

<!-- (For phones) Message in confirmation dialog informing user that
     they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] -->
    <string name="common_google_play_services_install_text_phone" msgid="2122112764540849864">This app won\'t run without Google Play services, which are missing from your phone.</string>

<!-- (For tablets) Message in confirmation dialog informing user that
    they need to install Google Play services (from Play Store) [CHAR LIMIT=NONE] -->
    <string name="common_google_play_services_install_text_tablet" msgid="7351599665250191022">This app won\'t run without Google Play services, which are missing from your tablet.</string>

哎呀! :-0 我甚至没有想到这不仅是一个我放置在其中的库的jar文件,而是一个我已经包含的项目。谢谢。 - user3037660

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接