user3037660
user3037660

Reputation: 43

Optional install of Google Play Services

I'm working on an Android app that wants to use Google Cloud Messaging. This in turn requires Google Play Services. The Android developer site goes through how to check whether Google Play Services is available, and if not use an error code to be passed on to GooglePlayServicesUtil.getErrorDialog(), to display a localized dialog allowing the user to jump to Play Store to install Google Play Services or Settings to enable it.

An initial test following this logic for the SERVICE_MISSING condition displays a dialog that says "This app won't run without Google Play services, which are missing from your phone."

However, in my case, Google Cloud Messaging (and therefore Google Play Services) is wanted only to support an optional feature. It is incorrect to say that the app "won't run". But that text comes from within GooglePlayServicesUtil.

Instead of using getErrorDialog() I could construct my own dialog with the text of my choice, but as far as I can see the Play Store URL for Play Services is not publicly available. I haven't experimented yet, but I can foresee a similar problem looming for the SERVICE_DISABLED path.

Anyone know of a way to mesh app-specific text with GooglePlayServicesUtil's secretive actions?

Upvotes: 4

Views: 970

Answers (1)

MH.
MH.

Reputation: 45493

Since the resources of the Google Play Services reside in a library project, you should be able to just override them in your own app. You'll find the following in the strings.xml file (amongst other strings):

<!-- (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>

Upvotes: 3

Related Questions