本文整理了Java中com.google.android.gms.common.api.Status
类的一些代码示例,展示了Status
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Status
类的具体详情如下:
包路径:com.google.android.gms.common.api.Status
类名称:Status
[英]Represents the results of work.
[中]代表工作的结果。
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
Toast
.makeText(getActivity(),
R.string.location_req_success_msg,
Toast.LENGTH_LONG)
.show();
} else {
Toast
.makeText(getActivity(), status.getStatusMessage(),
Toast.LENGTH_LONG)
.show();
getActivity().finish();
}
}
});
代码示例来源:origin: commonsguy/cw-omnibus
boolean thingsPlumbBusted=true;
switch(result.getStatus().getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
requestLocations();
result
.getStatus()
.startResolutionForResult(getActivity(),
SETTINGS_REQUEST_ID);
thingsPlumbBusted=false;
代码示例来源:origin: google/santa-tracker-android
@Override
public void onResult(Status status) {
if (status.isSuccess()) {
SantaLog.v(
TAG,
String.format(
"App Indexing API: Recorded ["
+ title
+ "] view successfully."));
} else {
SantaLog.e(
TAG,
"App Indexing API: There was an error recording the view."
+ status.toString());
}
}
});
代码示例来源:origin: retomeier/Wrox-ProfessionalAndroid-4E
@Override
public void onResult(@NonNull Status status) {
if(!status.isSuccess()) {
Log.d(TAG, "Fence could not be removed: " + status);
}
}
});
代码示例来源:origin: Michenux/YourAppIdea
public void onResult(Status status) {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
try {
status.startResolutionForResult(
AroundMeFragment.this.getActivity(), // your current activity used to receive the result
LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering
} catch (IntentSender.SendIntentException e) {
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e);
}
} else {
// No recovery. Weep softly or inform the user.
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage());
}
}
});
代码示例来源: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: 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: 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: googlesamples/android-play-places
/**
* Callback invoked when PlaceAutocompleteFragment encounters an error.
*/
@Override
public void onError(Status status) {
Log.e(TAG, "onError: Status = " + status.toString());
Toast.makeText(this, "Place selection failed: " + status.getStatusMessage(),
Toast.LENGTH_SHORT).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: UdacityAndroidDevScholarship/gis-2k18
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
Log.i(TAG, "onActivityResult: "+result);
Log.i(TAG, "onActivityResult: "+result.getStatus());
Log.i(TAG, "onActivityResult: "+result.getSignInAccount());
Log.i(TAG, "onActivityResult: "+result.isSuccess());
Log.i(TAG, "onActivityResult: "+result.toString());
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// [START_EXCLUDE]
Toast.makeText(LoginActivity.this, "Error", Toast.LENGTH_SHORT).show();
Log.i(TAG, "onActivityResult: "+result.getStatus().getStatusMessage());
// [END_EXCLUDE]
}
hideProgress();
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
代码示例来源:origin: ShlMlkzdh/RxSmartLock
@Override
public void onError(Throwable e) {
if (e instanceof StatusException) {
Status status = ((StatusException) e).getStatus();
if (status.hasResolution()) {
try {
status.startResolutionForResult(MainActivity.this, CREDENTIAL_REQUEST_RC);
} catch (IntentSender.SendIntentException e1) {
Log.e(TAG, "STATUS: Failed to send resolution.");
}
} else {
// The user must create an account or sign in manually.
Log.e(TAG, "STATUS: Unsuccessful credential request.");
}
}
}
代码示例来源:origin: chat-sdk/chat-sdk-android
@Override
public Completable loginWithGoogle(final Activity activity) {
return Single.create((SingleOnSubscribe<AuthCredential>) e -> {
googleClient = new GoogleApiClient.Builder(activity)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleClient);
activity.startActivityForResult(signInIntent, RC_GOOGLE_SIGN_IN);
googleSignInCompleteListener = result -> {
if(result.isSuccess()) {
AuthCredential credential = GoogleAuthProvider.getCredential(result.getSignInAccount().getIdToken(), null);
e.onSuccess(credential);
}
else {
e.onError(new Exception(result.getStatus().toString()));
}
};
}).flatMapCompletable(authCredential -> signInWithCredential(activity, authCredential));
}
代码示例来源:origin: yayaa/LocationManager
void startSettingsApiResolutionForResult(Status status, Activity activity) throws SendIntentException {
status.startResolutionForResult(activity, RequestCode.SETTINGS_API);
}
代码示例来源:origin: googlesamples/android-nearby
@Override
public void onResult(@NonNull Status status) {
if (status.isSuccess()) {
Log.i(TAG, "Subscribed successfully.");
} else {
logAndShowSnackbar("Could not subscribe, status = " + status);
mSubscribeSwitch.setChecked(false);
}
}
});
代码示例来源:origin: Michenux/YourAppIdea
@SuppressWarnings({"MissingPermission"})
private void registerLocationUpdates() {
PendingResult<Status> result = LocationServices.FusedLocationApi
.requestLocationUpdates(
mGoogleApiClient,
mRequest,
this);
result.setResultCallback(status -> {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
try {
status.startResolutionForResult(
SimpleMapFragment.this.getActivity(), // your current activity used to receive the result
LOCATIONSERVICES_RESOLUTION_RESULCODE); // the result code you'll look for in your onActivityResult method to retry registering
} catch (IntentSender.SendIntentException e) {
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment start resolution failure: ", e);
}
} else {
// No recovery. Weep softly or inform the user.
Log.e(YourApplication.LOG_TAG, "SimpleMapFragment registering failed: " + status.getStatusMessage());
}
});
}
代码示例来源: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: 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: mukeshsolanki/social-login-helper-Deprecated-
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_SIGN_IN) {
final GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
AsyncTask<Void, Void, String> task = new AsyncTask<Void, Void, String>() {
@Override protected String doInBackground(Void... params) {
String token = null;
try {
token =
GoogleAuthUtil.getToken(mContext, result.getSignInAccount().getAccount(), SCOPES);
} catch (IOException | GoogleAuthException e) {
e.printStackTrace();
}
return token;
}
@Override protected void onPostExecute(String token) {
GoogleSignInAccount acct = result.getSignInAccount();
mListener.onGoogleAuthSignIn(token, acct.getId());
}
};
task.execute();
} else {
mListener.onGoogleAuthSignInFailed(result.getStatus().getStatusMessage());
}
}
}
内容来源于网络,如有侵权,请联系作者删除!