android - 可选安装 Google Play 服务

标签 android google-play-services

我正在开发一个想要使用 Google 云消息传递的 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 的 secret 操作相结合的方法吗?

最佳答案

由于 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>

关于android - 可选安装 Google Play 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20224981/

相关文章:

安卓 M : Effect of Selective Permissions on Ads

Android Studio新建项目Eclipse风格

java - 如何将多个视频文件一起写入以创建一个视频文件

android - 移除 Action Bar Android

google-maps - 找不到 MapActivity。安卓工作室 0.5.1

android - Social.localUser.Authenticate 回调从未调用过

android - 如何防止 onItemSelected 在新实例化的 Spinner 上触发?

android - 音频文件的编码和解码,以通过Internet发送以减小尺寸。安卓

android - 应用程序签名证书和上传证书具有相同的指纹

android - Google Play 服务泄露