/**
   * Show a dialog returned by Google Play services for the connection error code
   *
   * @param errorCode An error code returned from onConnectionFailed
   */
  private void showErrorDialog(int errorCode) {
    // Get the error dialog from Google Play services
    Dialog errorDialog =
        GooglePlayServicesUtil.getErrorDialog(
            errorCode, this, LocationUtils.CONNETION_FAILURE_RESOLUTION_REQUEST);

    // If Google Play services can provide an error dialog
    if (errorDialog != null) {

      // Create a new DialogFragment in which to show the error dialog
      ErrorFragment errorFragment = new ErrorFragment();

      // Set the dialog in the DialogFragment
      errorFragment.setDialog(errorDialog);

      // Show the error dialog in the DialogFragment
      errorFragment.show(getFragmentManager(), LocationUtils.APPTAG);
    }
  }
  @SuppressWarnings("NewApi")
  private boolean serviceConnected() {
    // check google play service is available
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

    // available
    if (ConnectionResult.SUCCESS == resultCode) {
      Log.d(LocationUtils.APPTAG, getString(R.string.play_services_available));
      return true;
    } else {
      Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this, 0);
      if (dialog != null) {
        ErrorFragment errorFragment = new ErrorFragment();
        errorFragment.setDialog(dialog);
        errorFragment.show(getFragmentManager(), LocationUtils.APPTAG);
      }
      return false;
    }
  }