【问题标题】:How do I change the text shown in GooglePlayServicesUtil.getErrorDialog()?如何更改 GooglePlayServicesUtil.getErrorDialog() 中显示的文本?
【发布时间】:2015-01-28 19:08:25
【问题描述】:

我正在尝试遵循 Google 文档中的 gcm 教程。他们说如果 Play Services 过期了就调用这个方法:

 GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 9000).show();

没关系,但它会显示一个对话框,显示“除非您更新 Google Play 服务,否则此应用将无法运行”并带有“更新”按钮。我想更改标题和消息文本。我的用户可以跳过更新,该应用程序仍将运行。他们只是不会收到推送通知。如何更改对话框的消息?

我想做这样的事情:

Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 9000);
errorDialog.setTitle("out of date");
errorDialog.setMessage("Please update or push notifications won't work. Thank you");
errorDialog.show();

【问题讨论】:

  • 试试我的答案。它应该可以工作。

标签: java android google-play-services google-cloud-messaging android-dialog


【解决方案1】:

您可以像这样覆盖应用程序的strings.xml 中所需的字符串值。只需将这些行添加到您的 strings.xml

对话框中的消息

<string name="common_google_play_services_update_text" msgid="448354684997260580">This app won\'t run unless you update Google Play services.</string>

对话框标题

<string name="common_google_play_services_update_title" msgid="6006316683626838685">out of date</string>

编辑 你可以在这里找到更多信息 http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/What's the meaning of attribute 'msgid' in strings.xml?

msgid 在 android 内部字符串中用于本地化,但我从未找到任何有关它的文档。我有两个参考如上。我相信如果您删除 msgid 仍然可以工作,尽管我从未尝试过。

这段代码的来源是

android_sdk\extras\google\google_play_services\libproject\google-play-services_lib\res\values\common_strings.xml

【讨论】:

  • 成功了!为什么以及如何?这两个字符串中 msgid="" 的目的是什么?您可以将我链接到此文档或源代码吗?谢谢!
猜你喜欢
  • 2018-01-23
  • 2022-12-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-07
  • 2011-10-13
  • 2016-04-21
  • 2016-05-14
相关资源
最近更新 更多