如何更改GooglePlayServicesUtil.getErrorDialog()中显示的文字?

时间:2015-01-28 19:08:25

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

我正在尝试使用Googles文档中的gcm教程。如果Play服务已过期,他们会说这个方法:

 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();

1 个答案:

答案 0 :(得分:4)

您可以像这样在应用程序的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