Java Code Examples for androidx.appcompat.app.AppCompatActivity#RESULT_CANCELED

The following examples show how to use androidx.appcompat.app.AppCompatActivity#RESULT_CANCELED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RNFileSelectorModule.java    From react-native-file-selector with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {

  if (requestCode == 1 && resultCode == AppCompatActivity.RESULT_OK) {
    String filePath = data.getStringExtra(FilePickerActivity.RESULT_FILE_PATH);

    if (onDone != null) {
      onDone.invoke(filePath);
    }

    onDone = null;
  } else if (requestCode == 1 && resultCode == AppCompatActivity.RESULT_CANCELED) {
    if (onCancel != null) {
      onCancel.invoke();
    }

    onCancel = null;
  }
}
 
Example 2
Source File: RNVoiceRecorderModule.java    From react-native-voice-recorder with Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {

  if (resultCode == AppCompatActivity.RESULT_OK) {
    String filePath = Environment.getExternalStorageDirectory() + "/recorded_audio.wav";
    
    if (_onDone != null) {
      _onDone.invoke(filePath);
    }

    _onDone = null;
  } else if (resultCode == AppCompatActivity.RESULT_CANCELED) {
    if (_onCancel != null) {
      _onCancel.invoke();
    }

    _onCancel = null;
  }
}
 
Example 3
Source File: GameHelperUtils.java    From Asteroid with Apache License 2.0 6 votes vote down vote up
static String activityResponseCodeToString(int respCode) {
    switch (respCode) {
        case AppCompatActivity.RESULT_OK:
            return "RESULT_OK";
        case AppCompatActivity.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);
    }
}
 
Example 4
Source File: Venmo.java    From braintree_android with MIT License 6 votes vote down vote up
static void onActivityResult(final BraintreeFragment fragment, int resultCode, Intent data) {
    if (resultCode == AppCompatActivity.RESULT_OK) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.success");
        String nonce = data.getStringExtra(EXTRA_PAYMENT_METHOD_NONCE);

        if (shouldVault(fragment.getApplicationContext()) && fragment.getAuthorization() instanceof ClientToken) {
            vault(fragment, nonce);
        } else {
            String venmoUsername = data.getStringExtra(EXTRA_USERNAME);
            VenmoAccountNonce venmoAccountNonce = new VenmoAccountNonce(nonce, venmoUsername, venmoUsername);
            fragment.postCallback(venmoAccountNonce);
        }
    } else if (resultCode == AppCompatActivity.RESULT_CANCELED) {
        fragment.sendAnalyticsEvent("pay-with-venmo.app-switch.canceled");
    }
}
 
Example 5
Source File: PayPal.java    From braintree_android with MIT License 5 votes vote down vote up
/**
 * The result from PayPal's request.
 *
 * @param fragment A {@link BraintreeFragment} used to process the request.
 * @param data Data associated with the result.
 */
protected static void onActivityResult(final BraintreeFragment fragment, int resultCode, Intent data) {
    Request request = getPersistedRequest(fragment.getApplicationContext());
    String paymentType = paymentTypeForRequest(request);
    String switchType = switchTypeForIntent(data);
    String eventPrefix = paymentType + "." + switchType;

    if (resultCode == AppCompatActivity.RESULT_OK && data != null && request != null) {
        Result result = PayPalOneTouchCore.parseResponse(fragment.getApplicationContext(), request, data);
        switch (result.getResultType()) {
            case Error:
                fragment.postCallback(new BrowserSwitchException(result.getError().getMessage()));
                fragment.sendAnalyticsEvent(eventPrefix + ".failed");
                break;
            case Cancel:
                fragment.postCancelCallback(BraintreeRequestCodes.PAYPAL);
                fragment.sendAnalyticsEvent(eventPrefix + ".canceled");
                break;
            case Success:
                onSuccess(fragment, data, request, result);
                fragment.sendAnalyticsEvent(eventPrefix + ".succeeded");
                break;
        }
    } else {
        fragment.sendAnalyticsEvent(eventPrefix + ".canceled");

        if (resultCode != AppCompatActivity.RESULT_CANCELED) {
            fragment.postCancelCallback(BraintreeRequestCodes.PAYPAL);
        }
    }
}
 
Example 6
Source File: BraintreeFragment.java    From braintree_android with MIT License 5 votes vote down vote up
@Override
public void onBrowserSwitchResult(int requestCode, BrowserSwitchResult browserSwitchResult, @Nullable Uri uri) {
    String type = "";
    Intent intent = new Intent()
            .putExtra(EXTRA_WAS_BROWSER_SWITCH_RESULT, true);

    switch (requestCode) {
        case BraintreeRequestCodes.PAYPAL:
            type = "paypal";
            break;
        case BraintreeRequestCodes.THREE_D_SECURE:
            type =  "three-d-secure";
            break;
        case BraintreeRequestCodes.LOCAL_PAYMENT:
            type = "local-payment";
            break;
    }

    int resultCode = AppCompatActivity.RESULT_FIRST_USER;
    if (browserSwitchResult == BrowserSwitchResult.OK) {
        resultCode = AppCompatActivity.RESULT_OK;
        sendAnalyticsEvent(type + ".browser-switch.succeeded");
    } else if (browserSwitchResult == BrowserSwitchResult.CANCELED) {
        resultCode = AppCompatActivity.RESULT_CANCELED;
        sendAnalyticsEvent(type + ".browser-switch.canceled");
    } else if (browserSwitchResult == BrowserSwitchResult.ERROR) {
        if (browserSwitchResult.getErrorMessage().startsWith("No installed activities")) {
            sendAnalyticsEvent(type + ".browser-switch.failed.no-browser-installed");
        } else {
            sendAnalyticsEvent(type + ".browser-switch.failed.not-setup");
        }
    }

    onActivityResult(requestCode, resultCode, intent.setData(uri));
}
 
Example 7
Source File: BraintreeFragment.java    From braintree_android with MIT License 5 votes vote down vote up
@Override
public void onActivityResult(final int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case BraintreeRequestCodes.PAYPAL:
            PayPal.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.THREE_D_SECURE:
            ThreeDSecure.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.VENMO:
            Venmo.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.VISA_CHECKOUT:
            VisaCheckoutFacade.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.LOCAL_PAYMENT:
            LocalPayment.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.GOOGLE_PAYMENT:
            GooglePayment.onActivityResult(this, resultCode, data);
            break;
        case BraintreeRequestCodes.PAYPAL_TWO_FACTOR_AUTH:
            PayPalTwoFactorAuth.onActivityResult(this, resultCode, data);
            break;
    }

    if (resultCode == AppCompatActivity.RESULT_CANCELED) {
        postCancelCallback(requestCode);
    }
}
 
Example 8
Source File: GameHelper.java    From Asteroid with Apache License 2.0 4 votes vote down vote up
/**
 * 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 == AppCompatActivity.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 == AppCompatActivity.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));
    }
}