本文整理汇总了Java中android.app.Activity.RESULT_CANCELED属性的典型用法代码示例。如果您正苦于以下问题:Java Activity.RESULT_CANCELED属性的具体用法?Java Activity.RESULT_CANCELED怎么用?Java Activity.RESULT_CANCELED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.RESULT_CANCELED属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processPickedLocation
private void processPickedLocation(int resultCode, Intent data){
if (resultCode == Activity.RESULT_CANCELED) {
if (data.getExtras() == null)
return;
if (data.getExtras().containsKey(ChatSDKLocationActivity.ERROR))
uiHelper.showAlertToast(data.getExtras().getString(ChatSDKLocationActivity.ERROR));
}
else if (resultCode == Activity.RESULT_OK) {
if (DEBUG)
Timber.d("Zoom level: %s", data.getFloatExtra(ChatSDKLocationActivity.ZOOM, 0.0f));
// Send the message, Params Latitude, Longitude, Base64 Representation of the image of the location, threadId.
sendLocationMessage(data);
}
}
示例2: activityResponseCodeToString
static String activityResponseCodeToString(int respCode) {
switch (respCode) {
case Activity.RESULT_OK:
return "RESULT_OK";
case Activity.RESULT_CANCELED:
return "RESULT_CANCELED";
case GamesActivityResultCodes.RESULT_APP_MISCONFIGURED:
return "RESULT_APP_MISCONFIGURED";
case GamesActivityResultCodes.RESULT_LEFT_ROOM:
return "RESULT_LEFT_ROOM";
case GamesActivityResultCodes.RESULT_LICENSE_FAILED:
return "RESULT_LICENSE_FAILED";
case GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED:
return "RESULT_RECONNECT_REQUIRED";
case GamesActivityResultCodes.RESULT_SIGN_IN_FAILED:
return "SIGN_IN_FAILED";
default:
return String.valueOf(respCode);
}
}
示例3: processPickedPhoto
private void processPickedPhoto(int resultCode, Intent data){
switch (resultCode)
{
case Activity.RESULT_OK:
Uri uri = data.getData();
mFileName = DaoCore.generateEntity();
// If enabled we will save the image to the app
// directory in gallery else we will save it in the cache dir.
File dir;
if (BDefines.Options.SaveImagesToDir)
dir = Utils.ImageSaver.getAlbumStorageDir(activity.get(), Utils.ImageSaver.IMAGE_DIR_NAME);
else
dir = this.activity.get().getCacheDir();
if (dir == null)
{
uiHelper.dismissProgressCard();
uiHelper.showAlertToast(R.string.unable_to_fetch_image);
return;
}
Uri outputUri = Uri.fromFile(new File(dir, mFileName + ".jpeg"));
crop = new Cropper(uri);
Intent cropIntent = crop.getAdjustIntent(this.activity.get(), outputUri);
int request = Crop.REQUEST_CROP + PHOTO_PICKER_ID;
activity.get().startActivityForResult(cropIntent, request);
return;
case Activity.RESULT_CANCELED:
uiHelper.dismissProgressCard();
}
}
示例4: onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case LOAD_PAYMENT_DATA_REQUEST_CODE:
switch (resultCode) {
case Activity.RESULT_OK:
PaymentData paymentData = PaymentData.getFromIntent(data);
handlePaymentSuccess(paymentData);
break;
case Activity.RESULT_CANCELED:
// Nothing to here normally - the user simply cancelled without selecting a
// payment method.
break;
case AutoResolveHelper.RESULT_ERROR:
Status status = AutoResolveHelper.getStatusFromIntent(data);
handleError(status.getStatusCode());
break;
}
// Re-enables the Pay with Google button.
mPwgButton.setClickable(true);
break;
}
}
示例5: onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == RC_SIGN_IN) {
IdpResponse response = IdpResponse.fromResultIntent(data);
if(resultCode == Activity.RESULT_OK) {
Toast.makeText(this,"Signed in!", Toast.LENGTH_SHORT).show();
startActivity(new Intent(this,MyLocation.class).putExtra("my_token", response.getIdpToken()));
finish();
return;
} else if(resultCode == Activity.RESULT_CANCELED) {
Toast.makeText(this,"Sign In cancelled.", Toast.LENGTH_SHORT).show();
finish();
}
}
}
示例6: onRequestLocationResult
/**
* Handle action after receiving the resquest location intent
*
* @param resultCode
*/
public void onRequestLocationResult(int resultCode) {
switch (resultCode) {
case Activity.RESULT_OK:
//Ask for new versions
new CenterMapInLocation().execute();
break;
case Activity.RESULT_CANCELED:
break;
}
}
示例7: onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CHECK_SETTINGS:
switch (resultCode) {
case Activity.RESULT_OK:
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
ActivityCompat.checkSelfPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_LOCATION);
} else {
// Start location updates
// Note - in emulator location appears to be null if no other app is using GPS at time.
// So if just turning on device's location services getLastLocation will likely not
// return anything
//Toast.makeText(context, "starting GPS updates", Toast.LENGTH_LONG).show();
mFusedLocationClient.requestLocationUpdates(mLocationRequest, mLocationCallback, null);
locUpdates = true;
}
break;
case Activity.RESULT_CANCELED:
// user does not want to update setting. Handle it in a way that it will to affect your app functionality
useGPS = false;
SharedPreferences.Editor edit = preferences.edit();
edit.putBoolean("use_device_location", false);
edit.apply();
settingsFragment.useDeviceLocation.setChecked(false);
settingsFragment.setLocSummary();
break;
}
break;
}
}
示例8: onActivityResult
@Override
@SuppressLint("NewApi")
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// handle result of pick image chooser
if (requestCode == CropImage.PICK_IMAGE_CHOOSER_REQUEST_CODE) {
if (resultCode == Activity.RESULT_CANCELED) {
// User cancelled the picker. We don't have anything to crop
setResultCancel();
}
if (resultCode == Activity.RESULT_OK) {
mCropImageUri = CropImage.getPickImageResultUri(this, data);
// For API >= 23 we need to check specifically that we have permissions to read external
// storage.
if (CropImage.isReadExternalStoragePermissionsRequired(this, mCropImageUri)) {
// request permissions and handle the result in onRequestPermissionsResult()
requestPermissions(
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
CropImage.PICK_IMAGE_PERMISSIONS_REQUEST_CODE);
} else {
// no permissions required or already grunted, can start crop image activity
mCropImageView.setImageUriAsync(mCropImageUri);
}
}
}
}
示例9: onActivityResult
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_OAUTH) {
mAuthInProgress = false;
if (resultCode == Activity.RESULT_OK) {
// Make sure the app is not already connected or attempting to connect
if (!mApiClient.isConnecting() && !mApiClient.isConnected()) {
mApiClient.connect();
}
} else if (resultCode == Activity.RESULT_CANCELED) {
Log.e(TAG, "Authorization - Cancel");
}
}
}
示例10: onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
//super.onActivityResult(requestCode, resultCode, data);
if(resultCode != Activity.RESULT_CANCELED){
if (data != null) {
Uri uri = data.getData();
if (uri != null) {
Cursor c = null;
try {
c = getContentResolver().query(uri, new String[]{
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.TYPE },
null, null, null);
if (c != null && c.moveToFirst()) {
String number = c.getString(0);
int type = c.getInt(1);
if(one)
{
showSelectedNumber1(type, number);
}
else if(two)
{
showSelectedNumber2(type, number);
}
else if(three)
{
showSelectedNumber3(type, number);
}
else if(four)
{
showSelectedNumber4(type, number);
}
}
else
{
Toast.makeText(SOS_Contacts.this, "c is null",
Toast.LENGTH_LONG).show();
}
}
catch(Exception e)
{
Toast.makeText(SOS_Contacts.this, "Something went wrong. Try again",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
finally {
if (c != null) {
c.close();
}
}
}
}}
}
示例11: onActivityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// 相机拍照完成后,返回图片路径
if (requestCode == REQUEST_CAMERA) {
if (resultCode == Activity.RESULT_OK) {
if (mTmpFile != null) {
if (mCallback != null) {
mCallback.onCameraShot(mTmpFile);
}
}
}
else {
if (mTmpFile != null && mTmpFile.exists()) {
mTmpFile.delete();
}
}
}
else if (requestCode == REQUEST_PREVIEW && data != null) {
resultList.clear();
resultList.addAll(data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT));
if (resultCode == Activity.RESULT_OK) {
Intent data1 = new Intent();
data.putExtra("selectedAsset", resultList);
getActivity().setResult(Activity.RESULT_OK, data);
getActivity().finish();
getActivity().overridePendingTransition(R.anim.zoom_none, R.anim.zoom_out);
}
else if (resultCode == Activity.RESULT_CANCELED) {
mImageAdapter.setDefaultSelected(resultList);
if (mCallback != null) {
mCallback.onBatchImagesSelected(resultList);
}
selectedImage.clear();
for (Folder folder : mResultFolder) {
for (Image image : folder.images) {
if (resultList.contains(image.path) && !selectedImage.contains(image)) {
selectedImage.add(image);
}
else if (!resultList.contains(image.path) && selectedImage.contains(image)) {
selectedImage.remove(image);
}
}
}
if (resultList.size() != 0) {
mPreviewBtn.setEnabled(true);
}
else {
mPreviewBtn.setEnabled(false);
}
}
}
}
示例12: onActivityResult
/**
* Provides an implementation for {@link Activity#onActivityResult
* onActivityResult} that updates the Session based on information returned
* during the authorization flow. The Activity that calls open or
* requestNewPermissions should forward the resulting onActivityResult call here to
* update the Session state based on the contents of the resultCode and
* data.
*
* @param currentActivity The Activity that is forwarding the onActivityResult call.
* @param requestCode The requestCode parameter from the forwarded call. When this
* onActivityResult occurs as part of Facebook authorization
* flow, this value is the activityCode passed to open or
* authorize.
* @param resultCode An int containing the resultCode parameter from the forwarded
* call.
* @param data The Intent passed as the data parameter from the forwarded
* call.
* @return A boolean indicating whether the requestCode matched a pending
* authorization request for this Session.
*/
public final boolean onActivityResult(Activity currentActivity, int requestCode, int resultCode, Intent data) {
Validate.notNull(currentActivity, "currentActivity");
initializeStaticContext(currentActivity);
synchronized (lock) {
if (pendingAuthorizationRequest == null || (requestCode != pendingAuthorizationRequest.getRequestCode())) {
return false;
}
}
Exception exception = null;
AuthorizationClient.Result.Code code = AuthorizationClient.Result.Code.ERROR;
if (data != null) {
AuthorizationClient.Result result = (AuthorizationClient.Result) data.getSerializableExtra(
LoginActivity.RESULT_KEY);
if (result != null) {
// This came from LoginActivity.
handleAuthorizationResult(resultCode, result);
return true;
} else if (authorizationClient != null) {
// Delegate to the auth client.
authorizationClient.onActivityResult(requestCode, resultCode, data);
return true;
}
} else if (resultCode == Activity.RESULT_CANCELED) {
exception = new FacebookOperationCanceledException("User canceled operation.");
code = AuthorizationClient.Result.Code.CANCEL;
}
if (exception == null) {
exception = new FacebookException("Unexpected call to Session.onActivityResult");
}
logAuthorizationComplete(code, null, exception);
finishAuthOrReauth(null, exception);
return true;
}
示例13: postInstall
/**
* 3. Verify that install worked
*/
private void postInstall() {
int isInstalledCorrectly =
PrivilegedInstaller.isExtensionInstalledCorrectly(this);
String title;
String message;
final int result;
switch (isInstalledCorrectly) {
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_YES:
title = getString(R.string.system_install_post_success);
message = getString(R.string.system_install_post_success_message);
result = Activity.RESULT_OK;
break;
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_NO:
title = getString(R.string.system_install_post_fail);
message = getString(R.string.system_install_post_fail_message);
result = Activity.RESULT_CANCELED;
break;
case PrivilegedInstaller.IS_EXTENSION_INSTALLED_SIGNATURE_PROBLEM:
title = getString(R.string.system_install_post_fail);
message = getString(R.string.system_install_post_fail_message) +
"\n\n" + getString(R.string.system_install_denied_signature);
result = Activity.RESULT_CANCELED;
break;
default:
throw new RuntimeException("unhandled return");
}
// hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
AlertDialog.Builder builder = new AlertDialog.Builder(theme)
.setTitle(title)
.setMessage(message)
.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
InstallExtensionDialogActivity.this.setResult(result);
InstallExtensionDialogActivity.this.finish();
startActivity(new Intent(InstallExtensionDialogActivity.this, MainActivity.class));
}
})
.setCancelable(false);
builder.create().show();
}
示例14: onActivityResult
@Override
public void onActivityResult(int requestCode, int responseCode,
Intent intent) {
super.onActivityResult(requestCode, responseCode, intent);
switch (requestCode) {
case RC_SELECT_PLAYERS:
// we got the result from the "select players" UI -- ready to create the room
handleSelectPlayersResult(responseCode, intent);
break;
case RC_INVITATION_INBOX:
// we got the result from the "select invitation" UI (invitation inbox). We're
// ready to accept the selected invitation:
handleInvitationInboxResult(responseCode, intent);
break;
case RC_WAITING_ROOM:
// we got the result from the "waiting room" UI.
if (responseCode == Activity.RESULT_OK) {
// ready to start playing
Log.d(TAG, "Starting game (waiting room returned OK).");
startGame(true);
} else if (responseCode == GamesActivityResultCodes.RESULT_LEFT_ROOM) {
// player indicated that they want to leave the room
leaveRoom();
} else if (responseCode == Activity.RESULT_CANCELED) {
// Dialog was cancelled (user pressed back key, for instance). In our game,
// this means leaving the room too. In more elaborate games, this could mean
// something else (like minimizing the waiting room UI).
leaveRoom();
}
break;
case RC_SIGN_IN:
Log.d(TAG, "onActivityResult with requestCode == RC_SIGN_IN, responseCode="
+ responseCode + ", intent=" + intent);
mSignInClicked = false;
mResolvingConnectionFailure = false;
if (responseCode == RESULT_OK) {
mGoogleApiClient.connect();
} else {
BaseGameUtils.showActivityResultError(this,requestCode,responseCode, R.string.signin_other_error);
}
break;
}
super.onActivityResult(requestCode, responseCode, intent);
}
示例15: onActivityResult
/**
* Handle activity result. Call this method from your Activity's
* onActivityResult callback. If the activity result pertains to the sign-in
* process, processes it appropriately.
*/
public void onActivityResult(int requestCode, int responseCode,
Intent intent) {
debugLog("onActivityResult: req="
+ (requestCode == RC_RESOLVE ? "RC_RESOLVE" : String
.valueOf(requestCode)) + ", resp="
+ GameHelperUtils.activityResponseCodeToString(responseCode));
if (requestCode != RC_RESOLVE) {
debugLog("onActivityResult: request code not meant for us. Ignoring.");
return;
}
// no longer expecting a resolution
mExpectingResolution = false;
if (!mConnecting) {
debugLog("onActivityResult: ignoring because we are not connecting.");
return;
}
// We're coming back from an activity that was launched to resolve a
// connection problem. For example, the sign-in UI.
if (responseCode == Activity.RESULT_OK) {
// Ready to try to connect again.
debugLog("onAR: Resolution was RESULT_OK, so connecting current client again.");
connect();
} else if (responseCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
debugLog("onAR: Resolution was RECONNECT_REQUIRED, so reconnecting.");
connect();
} else if (responseCode == Activity.RESULT_CANCELED) {
// User cancelled.
debugLog("onAR: Got a cancellation result, so disconnecting.");
mSignInCancelled = true;
mConnectOnStart = false;
mUserInitiatedSignIn = false;
mSignInFailureReason = null; // cancelling is not a failure!
mConnecting = false;
mGoogleApiClient.disconnect();
// increment # of cancellations
int prevCancellations = getSignInCancellations();
int newCancellations = incrementSignInCancellations();
debugLog("onAR: # of cancellations " + prevCancellations + " --> "
+ newCancellations + ", max " + mMaxAutoSignInAttempts);
notifyListener(false);
} else {
// Whatever the problem we were trying to solve, it was not
// solved. So give up and show an error message.
debugLog("onAR: responseCode="
+ GameHelperUtils
.activityResponseCodeToString(responseCode)
+ ", so giving up.");
giveUp(new SignInFailureReason(mConnectionResult.getErrorCode(),
responseCode));
}
}