Пример Google Play Services: "connectionResult не может быть разрешен" - программирование
Подтвердить что ты не робот

Пример Google Play Services: "connectionResult не может быть разрешен"

когда я пытаюсь выполнить пример того, как проверить, установлены ли службы Google Play. Я получаю следующую ошибку: "connectionResult не может быть разрешен" в строке внутри servicesConnected method

int errorCode = connectionResult.getErrorCode();

Что может быть пропало? Я копирую и вставляю его. Я следую примеру здесь

Спасибо!

4b9b3361

Ответ 1

Это ошибка в примере. Используйте это вместо:

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

Ответ 2

решение о том, где было сказано, отсутствовало возвращение, заключалось в том, чтобы добавить return false в конец else, так пример:

еще       {           // Получить код ошибки

        // 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 
    }