com.google.android.gms.common.api.Status.getStatusCode()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(101)

本文整理了Java中com.google.android.gms.common.api.Status.getStatusCode()方法的一些代码示例,展示了Status.getStatusCode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status.getStatusCode()方法的具体详情如下:
包路径:com.google.android.gms.common.api.Status
类名称:Status
方法名:getStatusCode

Status.getStatusCode介绍

[英]Indicates the status of the operation.
[中]指示操作的状态。

代码示例

代码示例来源:origin: google/ExoPlayer

@Override
 public void onResult(@NonNull MediaChannelResult result) {
  int statusCode = result.getStatus().getStatusCode();
  if (statusCode != CastStatusCodes.SUCCESS && statusCode != CastStatusCodes.REPLACED) {
   Log.e(TAG, "Seek failed. Error code " + statusCode + ": "
     + CastUtils.getLogString(statusCode));
  }
  if (--pendingSeekCount == 0) {
   pendingSeekWindowIndex = C.INDEX_UNSET;
   pendingSeekPositionMs = C.TIME_UNSET;
   for (EventListener listener : listeners) {
    listener.onSeekProcessed();
   }
  }
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

boolean thingsPlumbBusted=true;
switch(result.getStatus().getStatusCode()) {
 case LocationSettingsStatusCodes.SUCCESS:
  requestLocations();

代码示例来源:origin: survivingwithandroid/Surviving-with-android

@Override
public void onConnectionResult(String s, ConnectionResolution connectionResolution) {
  switch (connectionResolution.getStatus().getStatusCode()) {
    case ConnectionsStatusCodes.STATUS_OK:
      listener.onConnected();
      break;
    case ConnectionsStatusCodes.STATUS_CONNECTION_REJECTED:
      Log.i(TAG, "Connection rejected");
      break;
    case ConnectionsStatusCodes.STATUS_ERROR:
      Log.i(TAG, "Connection error");
      break;
  }
}

代码示例来源:origin: googlesamples/android-nearby

@Override
  public void onResult(@NonNull Status status) {
    if (status.isSuccess()) {
      Log.i(TAG, "Subscribed successfully.");
      startService(getBackgroundSubscribeServiceIntent());
    } else {
      Log.e(TAG, "Operation failed. Error: " +
          NearbyMessagesStatusCodes.getStatusCodeString(
              status.getStatusCode()));
    }
  }
});

代码示例来源:origin: googlesamples/android-SynchronizedNotifications

@Override
  public void onResult(DataApi.DataItemResult dataItemResult) {
    if (!dataItemResult.getStatus().isSuccess()) {
      Log.e(TAG, "buildWatchOnlyNotification(): Failed to set the data, "
          + "status: " + dataItemResult.getStatus().getStatusCode());
    }
  }
});

代码示例来源:origin: bkhezry/MapDrawingTools

@Override
 public void onResult(@NonNull LocationSettingsResult locationSettingsResult) {
  final Status status = locationSettingsResult.getStatus();
  switch (status.getStatusCode()) {
   case LocationSettingsStatusCodes.SUCCESS:
    getLastKnowLocation();
    break;
   case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
    try {
     // Show the dialog by calling startResolutionForResult(),
     // and check the result in onActivityResult().
     status.startResolutionForResult(MapsActivity.this,
       REQUEST_CHECK_SETTINGS);
    } catch (IntentSender.SendIntentException e) {
     e.printStackTrace();
    }
    break;
   case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
    Log.e(TAG, "Error happen during show Dialog for Turn of GPS");
    break;
  }
 }
});

代码示例来源:origin: klaasnotfound/LocationAssistant

@Override
  public void onResult(@NonNull LocationSettingsResult result) {
    locationRequested = true;
    locationStatus = result.getStatus();
    switch (locationStatus.getStatusCode()) {
      case LocationSettingsStatusCodes.SUCCESS:
        locationStatusOk = true;
        checkInitialLocation();
        break;
      case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
        locationStatusOk = false;
        changeSettings = true;
        break;
      case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
        locationStatusOk = false;
        break;
    }
    acquireLocation();
  }
};

代码示例来源:origin: prabhat1707/EasyWayLocation

@Override
  public void onResult(@NonNull LocationSettingsResult result1) {
    Status status = result1.getStatus();
    final LocationSettingsStates states = result1.getLocationSettingsStates();
    switch (status.getStatusCode()) {
      case LocationSettingsStatusCodes.SUCCESS:
        mListener.locationOn();
        break;
      case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
        try {
          status.startResolutionForResult((Activity) context, LOCATION_SETTING_REQUEST_CODE);
        } catch (IntentSender.SendIntentException e) {
        }
        break;
      case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
        locationReturn = false;
        break;
    }
  }
});

代码示例来源:origin: florent37/RxGps

Status status = result.getStatus();
switch (status.getStatusCode()) {
  case LocationSettingsStatusCodes.SUCCESS:

代码示例来源:origin: jakehilborn/speedr

@Override
  public void onResult(@NonNull LocationSettingsResult result) {
    boolean showingLocationSettingsDialog = false;
    if (result.getStatus().getStatusCode() == LocationSettingsStatusCodes.RESOLUTION_REQUIRED) {
      try {
        //Show location settings change dialog and check the result in onActivityResult()
        result.getStatus().startResolutionForResult(MainActivity.this, REQUEST_LOCATION);
        showingLocationSettingsDialog = true;
        Crashlytics.log(Log.INFO, MainActivity.class.getSimpleName(), "Showing PlayServices GPS settings dialog");
      } catch (Exception e) {
        Crashlytics.log(Log.ERROR, MainActivity.class.getSimpleName(), "Error showing PlayServices GPS settings dialog");
        Crashlytics.logException(e);
      }
    }
    if (!showingLocationSettingsDialog) {
      showNoGPSAlert(); //Ask user to manually enable GPS
      googleApiClient.disconnect();
    }
  }
});

代码示例来源:origin: nglauber/dominando_android2

@Override
  public void onResult(LocationSettingsResult locationSettingsResult) {
    final Status status = locationSettingsResult.getStatus();
    switch (status.getStatusCode()) {
      case LocationSettingsStatusCodes.SUCCESS:
        obterUltimaLocalizacao();
        break;
      case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
        if (mDeveExibirDialog) {
          try {
            status.startResolutionForResult(MainActivity.this, REQUEST_CHECAR_GPS);
            mDeveExibirDialog = false;
          } catch (IntentSender.SendIntentException e) {
            e.printStackTrace();
          }
        }
        break;
      case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
        Log.wtf("NGVL", "Isso não deveria acontecer...");
        break;
    }
  }
});

代码示例来源:origin: patloew/RxFit

void getFitnessData() {
  fitnessSessionDataList.clear();
  view.showLoading();
  DataReadRequest.Builder dataReadRequestBuilder = getDataReadRequestBuilder();
  DataReadRequest dataReadRequest = dataReadRequestBuilder.build();
  DataReadRequest dataReadRequestServer = dataReadRequestBuilder.enableServerQueries().build();
  // First, request all data from the server. If there is an error (e.g. timeout),
  // switch to normal request
  disposable.add(
      rxFit.history().readBuckets(dataReadRequestServer)
        .doOnError(throwable -> { if(throwable instanceof StatusException && ((StatusException)throwable).getStatus().getStatusCode() == CommonStatusCodes.TIMEOUT) Log.e("MainActivity", "Timeout on server query request", throwable); })
        .compose(RxFitOnExceptionResumeNext.with(rxFit.history().readBuckets(dataReadRequest)))
        .subscribeOn(Schedulers.computation())
        .observeOn(AndroidSchedulers.mainThread())
        .subscribe(this::onBucketLoaded, this::onBucketLoadError, () -> view.onFitnessSessionDataLoaded(fitnessSessionDataList))
  );
}

代码示例来源:origin: yayaa/LocationManager

@Override
public void onResult(@NonNull LocationSettingsResult result) {
  final Status status = result.getStatus();
  switch (status.getStatusCode()) {
    case LocationSettingsStatusCodes.SUCCESS:
      // All location settings are satisfied. The client can initialize location
      // requests here.
      LogUtils.logI("We got GPS, Wifi and/or Cell network providers enabled enough "
         + "to receive location as we needed. Requesting location update...");
      requestLocationUpdate();
      break;
    case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
      // Location settings are not satisfied.
      // However, we have no way to fix the settings so we won't show the dialog.
      LogUtils.logE("Settings change is not available, SettingsApi failing...");
      settingsApiFail(FailType.GOOGLE_PLAY_SERVICES_SETTINGS_DIALOG);
      break;
    case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
      // Location settings are not satisfied. But could be fixed by showing the user
      // a dialog.
      resolveSettingsApi(status);
      break;
  }
}

代码示例来源:origin: nglauber/dominando_android2

@Override
  public void onResult(People.LoadPeopleResult loadPeopleResult) {
    mProgressBar.setVisibility(View.GONE);
    if (loadPeopleResult.getStatus().getStatusCode() == CommonStatusCodes.SUCCESS) {
      mProxPagina = loadPeopleResult.getNextPageToken();
      PersonBuffer personBuffer = loadPeopleResult.getPersonBuffer();
      try {
        if (mPessoas == null || mPessoas.isEmpty()) {
          mPessoas = new ArrayList<Pessoa>();
          mAdapter = new PessoaAdapter(getActivity(), mPessoas);
          mListView.setAdapter(mAdapter);
        }
        int count = personBuffer.getCount();
        for (int i = 0; i < count; i++) {
          Person person = personBuffer.get(i);
          mPessoas.add(new Pessoa(person.getDisplayName(), person.getImage().getUrl()));
        }
        mAdapter.notifyDataSetChanged();
      } finally {
        personBuffer.close();
      }
    } else {
      Toast.makeText(getActivity(),
          "Erro ao carregar contatos: " + loadPeopleResult.getStatus(),
          Toast.LENGTH_LONG).show();
    }
  }
}

代码示例来源:origin: dsolonenko/financisto

@Subscribe(threadMode = ThreadMode.MAIN)
public void onDriveBackupFailed(DriveBackupFailure event) {
  dismissProgressDialog();
  Status status = event.status;
  if (status.hasResolution()) {
    try {
      status.startResolutionForResult(this, RESOLVE_CONNECTION_REQUEST_CODE);
    } catch (IntentSender.SendIntentException e) {
      // Unable to resolve, message user appropriately
      onDriveBackupError(new DriveBackupError(e.getMessage()));
    }
  } else {
    GooglePlayServicesUtil.getErrorDialog(status.getStatusCode(), this, 0).show();
  }
}

代码示例来源:origin: braintree/braintree_android

@Test
  public void testGooglePaymentException_isSerializable() {
    Status status = new Status(1, "Some status message");
    GooglePaymentException exception = new GooglePaymentException("Some message", status);

    Parcel parcel = Parcel.obtain();
    exception.writeToParcel(parcel, 0);
    parcel.setDataPosition(0);

    GooglePaymentException actual = GooglePaymentException.CREATOR.createFromParcel(parcel);

    assertEquals("Some message", actual.getMessage());
    assertEquals("Some status message", actual.getStatus().getStatusMessage());
    assertEquals(1, actual.getStatus().getStatusCode());
  }
}

代码示例来源:origin: Michenux/YourAppIdea

private void handleSignInResult(GoogleSignInResult result) {
  if (BuildConfig.DEBUG) {
    Log.d(MCXApplication.LOG_TAG, "handleSignInResult:" + result.isSuccess() + " " + result.getStatus().getStatusCode() +
        result.getStatus().hasResolution());
  }
  if (result.isSuccess()) {
    // Signed in successfully, show authenticated UI.
    GoogleSignInAccount acct = result.getSignInAccount();
    User user = new User();
    user.setProvider(PROVIDER_NAME);
    user.setProviderDisplayName("Google+");
    user.setUserId(acct.getId());
    user.setUserName(acct.getId());
    user.setDisplayName(acct.getDisplayName());
    user.setMail(acct.getEmail());
    this.mUserHelper.setCurrentUser(user);
    if (this.mUserSessionCallback != null) {
      this.mUserSessionCallback.onLogin();
    }
  } else {
    // Signed out, show unauthenticated UI.
    this.mUserSessionCallback.onLogout();
  }
}

代码示例来源:origin: MrStahlfelge/gdx-gamesvcs

retryCount++;
int status = result.getStatus().getStatusCode();
Gdx.app.log(GAMESERVICE_ID, "Open Snapshot Result status: " + result.getStatus().getStatusMessage());

相关文章