【问题标题】:Optional install of Google Play Services可选安装 Google Play 服务
【发布时间】:2013-11-26 18:24:30
【问题描述】:

我正在开发一个想要使用 Google Cloud Messaging 的 Android 应用。这反过来又需要 Google Play 服务。 Android 开发者网站介绍了如何检查 Google Play 服务是否可用,如果不可用,则使用错误代码传递给 GooglePlayServicesUtil.getErrorDialog(),以显示本地化对话框,允许用户跳转到 Play 商店以安装 Google播放服务或设置以启用它。

按照 SERVICE_MISSING 条件的此逻辑进行的初始测试会显示一个对话框,显示“如果没有 Google Play 服务,此应用将无法运行,而您的手机中缺少这些服务。”

但是,就我而言,Google Cloud Messaging(以及因此的 Google Play 服务)只希望支持 可选 功能。说应用程序“不会运行”是不正确的。但该文本来自 GooglePlayServicesUtil。

我可以使用我选择的文本构建自己的对话框,而不是使用 getErrorDialog(),但据我所知,Play 服务的 Play 商店 URL 不公开。我还没有尝试过,但我可以预见到 SERVICE_DISABLED 路径会出现类似的问题。

有人知道将应用特定文本与 GooglePlayServicesUtil 的秘密操作相结合的方法吗?

【问题讨论】:

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

标签: android google-play-services


【解决方案1】:

由于 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 库,而是我包含的项目。谢谢。
猜你喜欢
  • 2014-03-13
  • 2018-03-25
  • 1970-01-01
  • 1970-01-01
  • 2014-08-30
  • 2013-09-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多