How do I change the text shown in GooglePlayServicesUtil.getErrorDialog()?

不问归期 提交于 2019-12-24 03:55:14

问题


I am trying to follow the gcm tutorial from Googles docs. They say to call this method if Play Services are out of date:

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

That's fine, but it puts a dialog that says "This app won't run unless you update Google Play Services" with an "Update" button. I want to change the title and the message text. My users CAN skip the update, and the app will still run. They just won't get push notifications. How do I change the message of the dialog?

I would like to do something like:

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:


You can override desired string value in your application's strings.xml like this. Simply add these lines in your strings.xml

For message on dialog

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

For title on dialog

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

EDIT You could find more information here http://blog.elsdoerfer.name/2010/04/08/android2po-managing-android-translations/ and What's the meaning of attribute 'msgid' in strings.xml?

msgid is used in android internal strings for localization but I never found any documentation about it. Two reference I have as above. I believe if you remove the msgid still it would work, although I never tried it.

The source of this code is

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


来源:https://stackoverflow.com/questions/28200416/how-do-i-change-the-text-shown-in-googleplayservicesutil-geterrordialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!