本文整理汇总了Java中com.google.android.gms.common.api.CommonStatusCodes类的典型用法代码示例。如果您正苦于以下问题:Java CommonStatusCodes类的具体用法?Java CommonStatusCodes怎么用?Java CommonStatusCodes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonStatusCodes类属于com.google.android.gms.common.api包,在下文中一共展示了CommonStatusCodes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PROFILE_REQUEST && resultCode == CommonStatusCodes.SUCCESS) {
preferences.setIdAuth("");
preferences.setUserData("");
preferences.setUserDni("");
preferences.setEmail("");
preferences.setIsLogged(false);
setDataToHeader(preferences);
if (!(getSupportFragmentManager().findFragmentById(R.id.containerHome) instanceof MapFragment)) {
navigationView.getMenu().getItem(0).setChecked(true);
setTitleToolbar(getString(R.string.map_stations));
getSupportFragmentManager().popBackStack("", FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
} else if (requestCode == 140) {
Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.containerHome);
if (fragment != null && fragment instanceof MapFragment) {
fragment.onActivityResult(requestCode, resultCode, data);
}
} else if (resultCode == Activity.RESULT_OK && requestCode == LoginActivity.LOGIN_RESULT) {
navigationView.getMenu().getItem(itemSelected).setChecked(true);
preferences.setIsLogged(true);
setDataToHeader(preferences);
}
}
示例2: handleSignInResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
protected void handleSignInResult(GoogleSignInResult result) {
Schedulers.newThread()
.scheduleDirect(() -> {
if (result.isSuccess()) {
if (result.getSignInAccount() != null && result.getSignInAccount().getAccount() != null) {
Account account = result.getSignInAccount().getAccount();
try {
String token = GoogleAuthUtil.getToken(activity, account, "oauth2:" + SCOPE_PICASA);
emitter.onSuccess(new GoogleSignIn.SignInAccount(token, result.getSignInAccount()));
} catch (IOException | GoogleAuthException e) {
emitter.onError(new SignInException("SignIn", e));
}
} else {
emitter.onError(new SignInException("SignIn", "getSignInAccount is null!", 0));
}
} else {
if (result.getStatus().getStatusCode() == CommonStatusCodes.SIGN_IN_REQUIRED) {
emitter.onError(new SignInRequiredException());
} else {
emitter.onError(new SignInException("SignIn", result.getStatus().getStatusMessage(), result.getStatus().getStatusCode()));
}
}
});
}
示例3: onTap
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* onTap is called to capture the first TextBlock under the tap location and return it to
* the Initializing Activity.
*
* @param rawX - the raw position of the tap
* @param rawY - the raw position of the tap.
* @return true if the activity is ending.
*/
private boolean onTap(float rawX, float rawY) {
OcrGraphic graphic = mGraphicOverlay.getGraphicAtLocation(rawX, rawY);
TextBlock text = null;
if (graphic != null) {
text = graphic.getTextBlock();
if (text != null && text.getValue() != null) {
Intent data = new Intent();
data.putExtra(TextBlockObject, text.getValue());
setResult(CommonStatusCodes.SUCCESS, data);
finish();
}
else {
Log.d(TAG, "text data is null");
}
}
else {
Log.d(TAG,"no text detected");
}
return text != null;
}
示例4: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* Called when an activity you launched exits, giving you the requestCode
* you started it with, the resultCode it returned, and any additional
* data from it. The <var>resultCode</var> will be
* {@link #RESULT_CANCELED} if the activity explicitly returned that,
* didn't return any result, or crashed during its operation.
* <p/>
* <p>You will receive this call immediately before onResume() when your
* activity is re-starting.
* <p/>
*
* @param requestCode The integer request code originally supplied to
* startActivityForResult(), allowing you to identify who this
* result came from.
* @param resultCode The integer result code returned by the child activity
* through its setResult().
* @param data An Intent, which can return result data to the caller
* (various data can be attached to Intent "extras").
* @see #startActivityForResult
* @see #createPendingResult
* @see #setResult(int)
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == RC_OCR_CAPTURE) {
if (resultCode == CommonStatusCodes.SUCCESS) {
if (data != null) {
String text = data.getStringExtra(OcrCaptureActivity.TextBlockObject);
statusMessage.setText(R.string.ocr_success);
textValue.setText(text);
Log.d(TAG, "Text read: " + text);
} else {
statusMessage.setText(R.string.ocr_failure);
Log.d(TAG, "No Text captured, intent data is null");
}
} else {
statusMessage.setText(String.format(getString(R.string.ocr_error),
CommonStatusCodes.getStatusCodeString(resultCode)));
}
}
else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例5: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == BARCODE_READER_REQUEST_CODE) {
if (resultCode == CommonStatusCodes.SUCCESS) {
if (data != null) {
Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
QRURLParser parser = QRURLParser.getInstance();
String extracted_address = parser.extractAddressFromQrString(barcode.displayValue);
if (extracted_address == null) {
Toast.makeText(this, R.string.toast_qr_code_no_address, Toast.LENGTH_SHORT).show();
return;
}
Point[] p = barcode.cornerPoints;
toAddressText.setText(extracted_address);
}
} else {
Log.e("SEND", String.format(getString(R.string.barcode_error_format),
CommonStatusCodes.getStatusCodeString(resultCode)));
}
} else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例6: resolveResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
private void resolveResult(Status status) {
if (status.getStatusCode() == CommonStatusCodes.RESOLUTION_REQUIRED) {
try {
//status.startResolutionForResult(mActivity, RC_READ);
startIntentSenderForResult(status.getResolution().getIntentSender(), RC_READ, null, 0, 0, 0, null);
} catch (IntentSender.SendIntentException e) {
e.printStackTrace();
mCredentialsApiClient.disconnect();
mAccountSubject.onError(new Throwable(e.toString()));
}
}
else {
// The user must create an account or sign in manually.
mCredentialsApiClient.disconnect();
mAccountSubject.onError(new Throwable(getString(R.string.status_canceled_request_credential)));
}
}
示例7: signOut
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* Facebook sign out
*/
public void signOut(PublishSubject<RxStatus> statusSubject) {
LoginManager.getInstance().logOut();
// delete current user
deleteCurrentUser();
statusSubject.onNext(new RxStatus(
CommonStatusCodes.SUCCESS,
getString(R.string.status_success_log_out_message)
));
statusSubject.onCompleted();
}
示例8: handleUnsuccessfulNearbyResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
private void handleUnsuccessfulNearbyResult(Status status) {
Log.v(TAG, "Processing error, status = " + status);
if (mResolvingError) {
// Already attempting to resolve an error.
return;
} else if (status.hasResolution()) {
try {
mResolvingError = true;
status.startResolutionForResult(getActivity(),
REQUEST_RESOLVE_ERROR);
} catch (IntentSender.SendIntentException e) {
mResolvingError = false;
Log.v(TAG, "Failed to resolve error status.", e);
}
} else {
if (status.getStatusCode() == CommonStatusCodes.NETWORK_ERROR) {
Toast.makeText(getActivity(),
"No connectivity, cannot proceed. Fix in 'Settings' and try again.",
Toast.LENGTH_LONG).show();
} else {
// To keep things simple, pop a toast for all other error messages.
Toast.makeText(getActivity(), "Unsuccessful: " +
status.getStatusMessage(), Toast.LENGTH_LONG).show();
}
}
}
示例9: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* Called when an activity you launched exits, giving you the requestCode
* you started it with, the resultCode it returned, and any additional
* data from it. The <var>resultCode</var> will be
* {@link #RESULT_CANCELED} if the activity explicitly returned that,
* didn't return any result, or crashed during its operation.
* <p/>
* <p>You will receive this call immediately before onResume() when your
* activity is re-starting.
* <p/>
*
* @param requestCode The integer request code originally supplied to
* startActivityForResult(), allowing you to identify who this
* result came from.
* @param resultCode The integer result code returned by the child activity
* through its setResult().
* @param data An Intent, which can return result data to the caller
* (various data can be attached to Intent "extras").
* @see #startActivityForResult
* @see #createPendingResult
* @see #setResult(int)
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == RC_OCR_CAPTURE) {
if (resultCode == CommonStatusCodes.SUCCESS) {
if (data != null) {
String text = data.getStringExtra(OcrCaptureActivity.TextBlockObject);
statusMessage.setText(R.string.ocr_success);
textValue.setText(text);
Log.d(TAG, "Text read: " + text);
} else {
statusMessage.setText(R.string.ocr_failure);
Log.d(TAG, "No Text captured, intent data is null");
}
} else {
statusMessage.setText(String.format(getString(R.string.ocr_error),
CommonStatusCodes.getStatusCodeString(resultCode)));
}
displayStatus();
}
else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例10: onFailure
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@Override
public void onFailure(@NonNull Exception e) {
// An error occurred while communicating with the service.
mResult = null;
if (e instanceof ApiException) {
// An error with the Google Play Services API contains some additional details.
ApiException apiException = (ApiException) e;
Log.d(TAG, "Error: " +
CommonStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " +
apiException.getStatusMessage());
} else {
// A different, unknown type of error occurred.
Log.d(TAG, "ERROR! " + e.getMessage());
}
}
示例11: handleUnsuccessfulNearbyResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@VisibleForTesting
protected void handleUnsuccessfulNearbyResult(Status status) {
Log.v(TAG, "Processing error, status = " + status);
if (resolvingError) {
// Already attempting to resolve an error.
return;
} else if (status.hasResolution()) {
try {
resolvingError = true;
status.startResolutionForResult(this, REQUEST_RESOLVE_ERROR);
} catch (Exception e) {
resolvingError = false;
Log.v(TAG, "Failed to resolve error status.", e);
}
} else {
if (status.getStatusCode() == CommonStatusCodes.NETWORK_ERROR) {
Toast.makeText(this,
"No connectivity, cannot proceed. Fix in 'Settings' and try again.",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(this, "Unsuccessful: " + status.getStatusMessage(),
Toast.LENGTH_LONG).show();
}
}
}
示例12: onTap
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* onTap is called to capture the oldest barcode currently detected and
* return it to the caller.
*
* @param rawX - the raw position of the tap
* @param rawY - the raw position of the tap.
* @return true if the activity is ending.
*/
private boolean onTap(float rawX, float rawY) {
//TODO: use the tap position to select the barcode.
BarcodeGraphic graphic = mGraphicOverlay.getFirstGraphic();
Barcode barcode = null;
if (graphic != null) {
barcode = graphic.getBarcode();
if (barcode != null) {
Intent data = new Intent();
data.putExtra(BarcodeObject, barcode);
setResult(CommonStatusCodes.SUCCESS, data);
finish();
}
else {
Log.d(TAG, "barcode data is null");
}
}
else {
Log.d(TAG,"no barcode detected");
}
return barcode != null;
}
示例13: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
/**
* Called when an activity you launched exits, giving you the requestCode
* you started it with, the resultCode it returned, and any additional
* data from it. The <var>resultCode</var> will be
* {@link #RESULT_CANCELED} if the activity explicitly returned that,
* didn't return any result, or crashed during its operation.
* <p/>
* <p>You will receive this call immediately before onResume() when your
* activity is re-starting.
* <p/>
*
* @param requestCode The integer request code originally supplied to
* startActivityForResult(), allowing you to identify who this
* result came from.
* @param resultCode The integer result code returned by the child activity
* through its setResult().
* @param data An Intent, which can return result data to the caller
* (various data can be attached to Intent "extras").
* @see #startActivityForResult
* @see #createPendingResult
* @see #setResult(int)
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == RC_BARCODE_CAPTURE) {
if (resultCode == CommonStatusCodes.SUCCESS) {
if (data != null) {
Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
statusMessage.setText(R.string.barcode_success);
barcodeValue.setText(barcode.displayValue);
Log.d(TAG, "Barcode read: " + barcode.displayValue);
} else {
statusMessage.setText(R.string.barcode_failure);
Log.d(TAG, "No barcode captured, intent data is null");
}
} else {
statusMessage.setText(String.format(getString(R.string.barcode_error),
CommonStatusCodes.getStatusCodeString(resultCode)));
}
}
else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例14: onActivityResult
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "onActivityResult");
if (requestCode == RC_BARCODE_CAPTURE) {
if (resultCode == CommonStatusCodes.SUCCESS) {
if (data != null) {
Barcode barcode = data.getParcelableExtra(BarcodeCaptureActivity.BarcodeObject);
Log.d(TAG, "Barcode read: " + barcode.displayValue);
mPresenter.newEvent(barcode);
} else {
Log.d(TAG, "No barcode captured, intent data is null");
}
} else {
Log.d(TAG, "onActivityResult is not a success");
}
}
else {
super.onActivityResult(requestCode, resultCode, data);
}
}
示例15: onConnected
import com.google.android.gms.common.api.CommonStatusCodes; //导入依赖的package包/类
@Override
public void onConnected(@Nullable Bundle bundle) {
googleApi.requestCredentials(new ResultCallback<CredentialRequestResult>() {
@Override
public void onResult(@NonNull CredentialRequestResult result) {
if (result.getStatus().isSuccess()) {
onCredentialRetrieved(result.getCredential());
} else if (result.getStatus().getStatusCode() != CommonStatusCodes.SIGN_IN_REQUIRED && result.getStatus().hasResolution()) {
try {
result.getStatus().startResolutionForResult(LoginActivity.this, GoogleApiAdapter.RETRIEVE_CREDENTIALS);
} catch (IntentSender.SendIntentException e) {
Snackbar.make(vLoginForm, R.string.error_smartlock_failed, Snackbar.LENGTH_LONG);
}
}
}
});
}