Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Services example: "connectionResult cannot be resolved"

when I'm trying to follow the example on how to check if Google Play Services is installed I receive the following error: "connectionResult cannot be resolved" in the line inside servicesConnected method

int errorCode = connectionResult.getErrorCode();

What can be missing? I'm copying and pasting it. I'm following the example here

Thanks!

like image 769
polonskyg Avatar asked Jun 25 '13 17:06

polonskyg


2 Answers

It's a bug in the example. Use this instead:

        } else {
        // Get the error code
        // Get the error dialog from Google Play services
        Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
                resultCode,
                this,
                CONNECTION_FAILURE_RESOLUTION_REQUEST);
like image 66
Joe Malin Avatar answered Sep 24 '22 06:09

Joe Malin


the solution to where it said there was a missing return was to add return false at the end of the else so example:

else { // Get the error code

        // Get the error dialog from Google Play services
        Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
                resultCode,
                this,
                CONNECTION_FAILURE_RESOLUTION_REQUEST);

        // If Google Play services can provide an error dialog
        if (errorDialog != null) {
            // Create a new DialogFragment for the error dialog
            ErrorDialogFragment errorFragment =
                    new ErrorDialogFragment();
            // Set the dialog in the DialogFragment
            errorFragment.setDialog(errorDialog);
            // Show the error dialog in the DialogFragment
            errorFragment.show(getSupportFragmentManager(),
                    "Location Updates");
        }
        return false;//THIS NEEDS TO BE FALSE 
    }
like image 24
NOAH BERRY Avatar answered Sep 24 '22 06:09

NOAH BERRY