Google Cloud Messaging: how to ask for google play services availability with GoogleApiAvailability Class

rudi

i want to work with google cloud messaging for my android app. it is said that you need to check for google play services availability first. but i don't know how to implement this. just searched through GoogleApiAvailability Class. Problem is i don't understand how to set up check and use method .getErrorDialog() in my case. It is said requestCode is "The requestCode given when calling startActivityForResult". but how to use it?

public void onResume() {
    GoogleApiAvailability availability = GoogleApiAvailability.getInstance();

    int checkForGPS = availability.isGooglePlayServicesAvailable(this);
    if(checkForGPS != ConnectionResult.SUCCESS) {
        availability.getErrorDialog(this, checkForGPS, requestCode);
    }
    super.onResume();
}
Ronak Joshi

Try this,

private boolean checkPlayServices() {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            GooglePlayServicesUtil.getErrorDialog(resultCode, this, PLAY_SERVICES_RESOLUTION_REQUEST).show();
        } else {
            Log.e(TAG, "This device is not supported.");
            finish();
        }
        return false;
    }
    return true;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Google Cloud Messaging for Android library vs. Google Play Services

From Dev

Having trouble configuring google play services for Google cloud messaging

From Dev

Using firebase cloud messaging in a device without Google Play Services

From Dev

Google Play Services with AdMob. Check availability?

From Dev

Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update

From Dev

Google Play Services 8.4.0 breaks Google Cloud Messaging for Android if iOS is also used

From Dev

New Google Play App and Firebase Cloud Messaging

From Dev

How do I check for Google Play Services API availability? (specifically the GCM API)

From Dev

Is it possible to ask user if he wants to update google play services or not?

From Dev

Where is the Auth class -- Google Play Services 8.3.0

From Dev

Google Cloud Messaging Unauthorized

From Dev

Google cloud messaging Limit

From Dev

Google Cloud Messaging in dart

From Dev

Google Cloud Messaging example

From Dev

QNetworkAccessManager for google cloud messaging

From Dev

Google Cloud Messaging / GCM

From Dev

How to push notifications to iOS with Google Cloud Messaging

From Dev

Google endpoints and Google Cloud Messaging

From Dev

Google Cloud Messaging VS Google Cloud Platform

From Dev

Google Cloud Messaging VS Google Cloud Platform

From Dev

How to interact with Google Play Services to query for images?

From Dev

How to download older google play services?

From Java

How to check Google Play services version?

From Dev

How does NodeAPI in Google Play Services work?

From Dev

How To Find Android Google Play Services Version

From Dev

How to remove Google Play Services from GenyMotion?

From Dev

How to properly update Google Play Services

From Dev

How To Find Android Google Play Services Version

From Dev

How to update Google Play Services through adb?

Related Related

  1. 1

    Google Cloud Messaging for Android library vs. Google Play Services

  2. 2

    Having trouble configuring google play services for Google cloud messaging

  3. 3

    Using firebase cloud messaging in a device without Google Play Services

  4. 4

    Google Play Services with AdMob. Check availability?

  5. 5

    Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update

  6. 6

    Google Play Services 8.4.0 breaks Google Cloud Messaging for Android if iOS is also used

  7. 7

    New Google Play App and Firebase Cloud Messaging

  8. 8

    How do I check for Google Play Services API availability? (specifically the GCM API)

  9. 9

    Is it possible to ask user if he wants to update google play services or not?

  10. 10

    Where is the Auth class -- Google Play Services 8.3.0

  11. 11

    Google Cloud Messaging Unauthorized

  12. 12

    Google cloud messaging Limit

  13. 13

    Google Cloud Messaging in dart

  14. 14

    Google Cloud Messaging example

  15. 15

    QNetworkAccessManager for google cloud messaging

  16. 16

    Google Cloud Messaging / GCM

  17. 17

    How to push notifications to iOS with Google Cloud Messaging

  18. 18

    Google endpoints and Google Cloud Messaging

  19. 19

    Google Cloud Messaging VS Google Cloud Platform

  20. 20

    Google Cloud Messaging VS Google Cloud Platform

  21. 21

    How to interact with Google Play Services to query for images?

  22. 22

    How to download older google play services?

  23. 23

    How to check Google Play services version?

  24. 24

    How does NodeAPI in Google Play Services work?

  25. 25

    How To Find Android Google Play Services Version

  26. 26

    How to remove Google Play Services from GenyMotion?

  27. 27

    How to properly update Google Play Services

  28. 28

    How To Find Android Google Play Services Version

  29. 29

    How to update Google Play Services through adb?

HotTag

Archive