Java Code Examples for com.google.android.gms.common.GooglePlayServicesUtil#getErrorDialog()

The following examples show how to use com.google.android.gms.common.GooglePlayServicesUtil#getErrorDialog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CastUtils.java    From UTubeTV with The Unlicense 6 votes vote down vote up
/**
 * A utility method to validate that the appropriate version of the Google Play Services is
 * available on the device. If not, it will open a dialog to address the issue. The dialog
 * displays a localized message about the error and upon user confirmation (by tapping on
 * dialog) will direct them to the Play Store if Google Play services is out of date or missing,
 * or to system settings if Google Play services is disabled on the device.
 */
public static boolean checkGooglePlayServices(final Activity activity) {
  final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
  switch (googlePlayServicesCheck) {
    case ConnectionResult.SUCCESS:
      return true;
    default:
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
      dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialogInterface) {
          activity.finish();
        }
      });
      dialog.show();
  }
  return false;
}
 
Example 2
Source File: BaseGameUtils.java    From android with Apache License 2.0 6 votes vote down vote up
/**
 * Resolve a connection failure from {@link GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(ConnectionResult)}
 *
 * @param activity             the Activity trying to resolve the connection failure.
 * @param client               the GoogleAPIClient instance of the Activity.
 * @param result               the ConnectionResult received by the Activity.
 * @param requestCode          a request code which the calling Activity can use to identify the
 *                             result of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be
 *                             resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity, GoogleApiClient client,
    ConnectionResult result, int requestCode, String fallbackErrorMessage) {
  if (result.hasResolution()) {
    try {
      result.startResolutionForResult(activity, requestCode);
      return true;
    } catch (IntentSender.SendIntentException e) {
      // The intent was canceled before it was sent.  Return to the default
      // state and attempt to connect to get an updated ConnectionResult.
      client.connect();
      return false;
    }
  } else {
    // not resolvable... so show an error message
    int errorCode = result.getErrorCode();
    Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode, activity, requestCode);
    if (dialog != null) {
      dialog.show();
    } else {
      // no built-in dialog: show the fallback error message
      showAlert(activity, fallbackErrorMessage);
    }
    return false;
  }
}
 
Example 3
Source File: ConnectionActivity.java    From Android-GSDemo-GoogleMap with MIT License 6 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {

        case R.id.btn_open: {
            int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
            if(status != ConnectionResult.SUCCESS) {
                GooglePlayServicesUtil.getErrorDialog(status, this, status);
                showToast("Cannot run without Google Play, please check!");
            } else {
                Intent intent = new Intent(this, MainActivity.class);
                startActivity(intent);
            }
            break;
        }
        default:
            break;
    }
}
 
Example 4
Source File: Utils.java    From android with Apache License 2.0 6 votes vote down vote up
/**
 * A utility method to validate that the appropriate version of the Google Play Services is
 * available on the device. If not, it will open a dialog to address the issue. The dialog
 * displays a localized message about the error and upon user confirmation (by tapping on
 * dialog) will direct them to the Play Store if Google Play services is out of date or missing,
 * or to system settings if Google Play services is disabled on the device.
 *
 * @param activity
 * @return
 */
public static boolean checkGooglePlayServices(final Activity activity) {
    final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(
            activity);
    switch (googlePlayServicesCheck) {
        case ConnectionResult.SUCCESS:
            return true;
        default:
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck,
                    activity, 0);
            dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    activity.finish();
                }
            });
            dialog.show();
    }
    return false;
}
 
Example 5
Source File: MockWalkerActivity.java    From AndroidProgramming3e with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();

    int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    if (errorCode != ConnectionResult.SUCCESS) {
        Dialog errorDialog = GooglePlayServicesUtil
                .getErrorDialog(errorCode, this, REQUEST_ERROR,
                        new DialogInterface.OnCancelListener() {

                            @Override
                            public void onCancel(DialogInterface dialog) {
                                // Leave if services are unavailable.
                                finish();
                            }
                        });

        errorDialog.show();
    }
}
 
Example 6
Source File: BaseGameUtils.java    From 8bitartist with Apache License 2.0 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil
                            .isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity,
                        activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
 
Example 7
Source File: BaseGameUtils.java    From gdx-gamesvcs with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}
 
Example 8
Source File: BaseGameUtils.java    From 8bitartist with Apache License 2.0 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
 
Example 9
Source File: BaseGameUtils.java    From android with Apache License 2.0 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *
 * @param activity         the Activity in which the Dialog should be displayed.
 * @param requestCode      the request code from onActivityResult.
 * @param actResp          the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp,
    int errorDescription) {
  if (activity == null) {
    Log.e(TAG, "*** No Activity. Can't show failure dialog!");
    return;
  }
  Dialog errorDialog;

  switch (actResp) {
    case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
      errorDialog = makeSimpleDialog(activity,
          activity.getString(R.string.app_misconfigured));
      break;
    case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
      errorDialog = makeSimpleDialog(activity,
          activity.getString(R.string.sign_in_failed));
      break;
    case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
      errorDialog = makeSimpleDialog(activity,
          activity.getString(R.string.license_failed));
      break;
    default:
      // No meaningful Activity response code, so generate default Google
      // Play services dialog
      final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
      errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
          activity, requestCode, null);
      if (errorDialog == null) {
        // get fallback dialog
        Log.e(TAG,
            "No standard error dialog available. Making fallback dialog.");
        errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
      }
  }

  errorDialog.show();
}
 
Example 10
Source File: BaseGameUtils.java    From FixMath with Apache License 2.0 5 votes vote down vote up
/**
 * Resolve a connection failure from
 * {@link com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener#onConnectionFailed(com.google.android.gms.common.ConnectionResult)}
 *
 * @param activity the Activity trying to resolve the connection failure.
 * @param client the GoogleAPIClient instance of the Activity.
 * @param result the ConnectionResult received by the Activity.
 * @param requestCode a request code which the calling Activity can use to identify the result
 *                    of this resolution in onActivityResult.
 * @param fallbackErrorMessage a generic error message to display if the failure cannot be resolved.
 * @return true if the connection failure is resolved, false otherwise.
 */
public static boolean resolveConnectionFailure(Activity activity,
                                               GoogleApiClient client, ConnectionResult result, int requestCode,
                                               String fallbackErrorMessage) {

    if (result.hasResolution()) {
        try {
            result.startResolutionForResult(activity, requestCode);
            return true;
        } catch (IntentSender.SendIntentException e) {
            // The intent was canceled before it was sent.  Return to the default
            // state and attempt to connect to get an updated ConnectionResult.
            client.connect();
            return false;
        }
    } else {
        // not resolvable... so show an error message
        int errorCode = result.getErrorCode();
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, requestCode);
        if (dialog != null) {
            dialog.show();
        } else {
            // no built-in dialog: show the fallback error message
            showAlert(activity, fallbackErrorMessage);
        }
        return false;
    }
}
 
Example 11
Source File: BaseGameUtils.java    From FlappyCow with MIT License 5 votes vote down vote up
/**
 * Show a {@link android.app.Dialog} with the correct message for a connection error.
 *  @param activity the Activity in which the Dialog should be displayed.
 * @param requestCode the request code from onActivityResult.
 * @param actResp the response code from onActivityResult.
 * @param errorDescription the resource id of a String for a generic error message.
 */
public static void showActivityResultError(Activity activity, int requestCode, int actResp, int errorDescription) {
    if (activity == null) {
        Log.e("BaseGameUtils", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.app_misconfigured));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.sign_in_failed));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity,
                    activity.getString(R.string.license_failed));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            final int errorCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, requestCode, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("BaseGamesUtils",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(activity, activity.getString(errorDescription));
            }
    }

    errorDialog.show();
}
 
Example 12
Source File: GooglePlayClientWrapper.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
public void onConnectionFailed(final ConnectionResult connectionResult) {
    mConnectionResult = connectionResult;
    /*
     * Google Play services can resolve some errors it detects. If the error
     * has a resolution, try sending an Intent to start a Google Play
     * services activity that can resolve error.
     */
    if (connectionResult.hasResolution()) {
        try {
            // Start an Activity that tries to resolve the error
            connectionResult.startResolutionForResult(mActivity, CONNECTION_FAILURE_RESOLUTION_REQUEST);
            /*
             * Thrown if Google Play services canceled the original
             * PendingIntent
             */
        } catch (final IntentSender.SendIntentException e) {
            //Logger the error
            e.printStackTrace();
        }
    } else {
        /*
         * If no resolution is available, display a dialog to the user with
         * the error.
         */
        // showErrorDialog(connectionResult.getErrorCode());

        final Dialog errorDialog = GooglePlayServicesUtil
                        .getErrorDialog(connectionResult.getErrorCode(), mActivity, CONNECTION_FAILURE_RESOLUTION_REQUEST);
        // If Google Play services can provide an error dialog
        if (errorDialog != null) {
            // Create a new DialogFragment for the error dialog
            final ErrorDialogFragment errorFragment = new ErrorDialogFragment();
            // Set the dialog in the DialogFragment
            errorFragment.setDialog(errorDialog);
            // Show the error dialog in the DialogFragment
            errorFragment.show(mActivity.getSupportFragmentManager(), "Location Updates");
        }
    }
}
 
Example 13
Source File: MapFragment.java    From MuslimMateAndroid with GNU General Public License v3.0 5 votes vote down vote up
private void setupGoogleService() {
    int statusCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity().getApplicationContext());
    if (statusCode == ConnectionResult.SUCCESS) {

        getMapAsync(this);

    } else {
        Dialog dialog = GooglePlayServicesUtil.getErrorDialog(statusCode, (Activity) context, INTENT_CODE);
        dialog.show();
    }
}
 
Example 14
Source File: MainActivity.java    From effective_android_sample with Apache License 2.0 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // getArguments()でエラーダイアログ生成に必要な引数を修得する
    int errorCode = getArguments().getInt(ERROR_CODE);

    // Google Play servicesでエラーダイアログを生成する
    Dialog errorDialog = GooglePlayServicesUtil.getErrorDialog(
            errorCode,
            getActivity(),
            CONNECTION_FAILURE_RESOLUTION_REQUEST
            );

    return errorDialog;
}
 
Example 15
Source File: GooglePlayClientWrapper.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
private boolean servicesConnected() {
    // Check that Google Play services is available
    final int resultCode = GooglePlayServicesUtil
                    .isGooglePlayServicesAvailable(mActivity);
    // If Google Play services is available
    if (ConnectionResult.SUCCESS == resultCode) {
        // In debug mode, log the status
        Logger.d("Location Updates", "Google Play services is available.");
        // Continue
        return true;
        // Google Play services was not available for some reason
    } else {

        if (mConnectionResult != null) {
            // Get the error code
            final int errorCode = mConnectionResult.getErrorCode();
            // Get the error dialog from Google Play services
            final Dialog errorDialog = GooglePlayServicesUtil
                            .getErrorDialog(errorCode, mActivity, CONNECTION_FAILURE_RESOLUTION_REQUEST);
            // If Google Play services can provide an error dialog
            if (errorDialog != null) {
                // Create a new DialogFragment for the error dialog
                final ErrorDialogFragment errorFragment = new ErrorDialogFragment();
                // Set the dialog in the DialogFragment
                errorFragment.setDialog(errorDialog);
                // Show the error dialog in the DialogFragment
                errorFragment.show(mActivity.getSupportFragmentManager(), "Location Updates");
            }
        }

        return false;
    }
}
 
Example 16
Source File: GameHelper.java    From FlappyCow with MIT License 4 votes vote down vote up
/** Shows an error dialog that's appropriate for the failure reason. */
public static void showFailureDialog(Activity activity, int actResp,
                                     int errorCode) {
    if (activity == null) {
        Log.e("GameHelper", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog = null;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_APP_MISCONFIGURED));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_SIGN_IN_FAILED));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_LICENSE_FAILED));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, RC_UNUSED, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("GameHelper",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(
                        activity,
                        GameHelperUtils.getString(activity,
                                GameHelperUtils.R_UNKNOWN_ERROR)
                                + " "
                                + GameHelperUtils.errorCodeToString(errorCode));
            }
    }

    errorDialog.show();
}
 
Example 17
Source File: GameHelper.java    From tedroid with Apache License 2.0 4 votes vote down vote up
/** Shows an error dialog that's appropriate for the failure reason. */
public static void showFailureDialog(Activity activity, int actResp,
                                     int errorCode) {
    if (activity == null) {
        Log.e("GameHelper", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog = null;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_APP_MISCONFIGURED));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_SIGN_IN_FAILED));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_LICENSE_FAILED));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, RC_UNUSED, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("GameHelper",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(
                        activity,
                        GameHelperUtils.getString(activity,
                                GameHelperUtils.R_UNKNOWN_ERROR)
                                + " "
                                + GameHelperUtils.errorCodeToString(errorCode));
            }
    }

    errorDialog.show();
}
 
Example 18
Source File: GameHelper.java    From martianrun with Apache License 2.0 4 votes vote down vote up
/**
 * Shows an error dialog that's appropriate for the failure reason.
 */
public static void showFailureDialog(Activity activity, int actResp,
                                     int errorCode) {
    if (activity == null) {
        Log.e("GameHelper", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog = null;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_APP_MISCONFIGURED));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_SIGN_IN_FAILED));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_LICENSE_FAILED));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, RC_UNUSED, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("GameHelper",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(
                        activity,
                        GameHelperUtils.getString(activity,
                                GameHelperUtils.R_UNKNOWN_ERROR)
                                + " "
                                + GameHelperUtils.errorCodeToString(errorCode));
            }
    }

    errorDialog.show();
}
 
Example 19
Source File: GameHelper.java    From io2014-codelabs with Apache License 2.0 4 votes vote down vote up
/** Shows an error dialog that's appropriate for the failure reason. */
public static void showFailureDialog(Activity activity, int actResp,
        int errorCode) {
    if (activity == null) {
        Log.e("GameHelper", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog = null;

    switch (actResp) {
    case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
        errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                activity, GameHelperUtils.R_APP_MISCONFIGURED));
        break;
    case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
        errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                activity, GameHelperUtils.R_SIGN_IN_FAILED));
        break;
    case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
        errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                activity, GameHelperUtils.R_LICENSE_FAILED));
        break;
    default:
        // No meaningful Activity response code, so generate default Google
        // Play services dialog
        errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                activity, RC_UNUSED, null);
        if (errorDialog == null) {
            // get fallback dialog
            Log.e("GameHelper",
                    "No standard error dialog available. Making fallback dialog.");
            errorDialog = makeSimpleDialog(
                    activity,
                    GameHelperUtils.getString(activity,
                            GameHelperUtils.R_UNKNOWN_ERROR)
                            + " "
                            + GameHelperUtils.errorCodeToString(errorCode));
        }
    }

    errorDialog.show();
}
 
Example 20
Source File: GameHelper.java    From Trivia-Knowledge with Apache License 2.0 4 votes vote down vote up
/** Shows an error dialog that's appropriate for the failure reason. */
public static void showFailureDialog(Activity activity, int actResp,
                                     int errorCode) {
    if (activity == null) {
        Log.e("GameHelper", "*** No Activity. Can't show failure dialog!");
        return;
    }
    Dialog errorDialog = null;

    switch (actResp) {
        case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_APP_MISCONFIGURED));
            break;
        case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_SIGN_IN_FAILED));
            break;
        case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
            errorDialog = makeSimpleDialog(activity, GameHelperUtils.getString(
                    activity, GameHelperUtils.R_LICENSE_FAILED));
            break;
        default:
            // No meaningful Activity response code, so generate default Google
            // Play services dialog
            errorDialog = GooglePlayServicesUtil.getErrorDialog(errorCode,
                    activity, RC_UNUSED, null);
            if (errorDialog == null) {
                // get fallback dialog
                Log.e("GameHelper",
                        "No standard error dialog available. Making fallback dialog.");
                errorDialog = makeSimpleDialog(
                        activity,
                        GameHelperUtils.getString(activity,
                                GameHelperUtils.R_UNKNOWN_ERROR)
                                + " "
                                + GameHelperUtils.errorCodeToString(errorCode));
            }
    }

    errorDialog.show();
}