问题
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!
回答1:
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);
回答2:
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
}
来源:https://stackoverflow.com/questions/17303941/google-play-services-example-connectionresult-cannot-be-resolved