List of usage examples for android.app Activity RESULT_CANCELED
int RESULT_CANCELED
To view the source code for android.app Activity RESULT_CANCELED.
Click Source Link
From source file:com.segma.trim.InAppBillingUtilities.InAppBillingHelper.java
/** * Handles an activity result that's part of the purchase flow in in-app billing. If you * are calling {@link #launchPurchaseFlow}, then you must call this method from your * Activity's {@link Activity@onActivityResult} method. This method * MUST be called from the UI thread of the Activity. * * @param requestCode The requestCode as you received it. * @param resultCode The resultCode as you received it. * @param data The data (Intent) as you received it. * @return Returns true if the result was related to a purchase flow and was handled; * false if the result was not related to a purchase, in which case you should * handle it normally./* w ww . j a v a 2 s .co m*/ */ public boolean handleActivityResult(int requestCode, int resultCode, Intent data) { InAppBillingResult result; if (requestCode != mRequestCode) return false; checkNotDisposed(); checkSetupDone("handleActivityResult"); // end of async purchase operation that started on launchPurchaseFlow flagEndAsync(); if (data == null) { logError("Null data in IAB activity result."); result = new InAppBillingResult(IABHELPER_BAD_RESPONSE, "Null data in IAB result"); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, null); return true; } int responseCode = getResponseCodeFromIntent(data); String purchaseData = data.getStringExtra(RESPONSE_INAPP_PURCHASE_DATA); String dataSignature = data.getStringExtra(RESPONSE_INAPP_SIGNATURE); if (resultCode == Activity.RESULT_OK && responseCode == BILLING_RESPONSE_RESULT_OK) { logDebug("Successful resultcode from purchase activity."); logDebug("Purchase data: " + purchaseData); logDebug("Data signature: " + dataSignature); logDebug("Extras: " + data.getExtras()); logDebug("Expected item type: " + mPurchasingItemType); if (purchaseData == null || dataSignature == null) { logError("BUG: either purchaseData or dataSignature is null."); logDebug("Extras: " + data.getExtras().toString()); result = new InAppBillingResult(IABHELPER_UNKNOWN_ERROR, "IAB returned null purchaseData or dataSignature"); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, null); return true; } Purchase purchase = null; try { purchase = new Purchase(mPurchasingItemType, purchaseData, dataSignature); String sku = purchase.getStockKeepingUnit(); // Verify signature if (!Security.verifyPurchase(mSignatureBase64, purchaseData, dataSignature)) { logError("Purchase signature verification FAILED for sku " + sku); result = new InAppBillingResult(IABHELPER_VERIFICATION_FAILED, "Signature verification failed for sku " + sku); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, purchase); return true; } logDebug("Purchase signature successfully verified."); } catch (JSONException e) { logError("Failed to parse purchase data."); e.printStackTrace(); result = new InAppBillingResult(IABHELPER_BAD_RESPONSE, "Failed to parse purchase data."); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, null); return true; } if (mPurchaseListener != null) { mPurchaseListener.onInAppBillingPurchaseFinished( new InAppBillingResult(BILLING_RESPONSE_RESULT_OK, "Success"), purchase); } } else if (resultCode == Activity.RESULT_OK) { // result code was OK, but in-app billing response was not OK. logDebug("Result code was OK but in-app billing response was not OK: " + getResponseDesc(responseCode)); if (mPurchaseListener != null) { result = new InAppBillingResult(responseCode, "Problem purchashing item."); mPurchaseListener.onInAppBillingPurchaseFinished(result, null); } } else if (resultCode == Activity.RESULT_CANCELED) { logDebug("Purchase canceled - Response: " + getResponseDesc(responseCode)); result = new InAppBillingResult(IABHELPER_USER_CANCELLED, "User canceled."); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, null); } else { logError("Purchase failed. Result code: " + Integer.toString(resultCode) + ". Response: " + getResponseDesc(responseCode)); result = new InAppBillingResult(IABHELPER_UNKNOWN_PURCHASE_RESPONSE, "Unknown purchase response."); if (mPurchaseListener != null) mPurchaseListener.onInAppBillingPurchaseFinished(result, null); } return true; }
From source file:es.ugr.swad.swadroid.modules.downloads.DownloadsManager.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { switch (requestCode) { case Constants.PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { init();/*w ww. jav a 2 s.c o m*/ } else { setResult(Activity.RESULT_CANCELED); finish(); } } } }
From source file:com.adafruit.bluefruit.le.connect.app.MainActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == kActivityRequestCode_ConnectedActivity) { if (resultCode < 0) { Toast.makeText(this, R.string.scan_unexpecteddisconnect, Toast.LENGTH_LONG).show(); }//from w w w . jav a 2 s. com } else if (requestCode == kActivityRequestCode_EnableBluetooth) { if (resultCode == Activity.RESULT_OK) { // Bluetooth was enabled, resume scanning resumeScanning(); } else if (resultCode == Activity.RESULT_CANCELED) { AlertDialog.Builder builder = new AlertDialog.Builder(this); AlertDialog dialog = builder.setMessage(R.string.dialog_error_no_bluetooth) .setPositiveButton(android.R.string.ok, null).show(); DialogUtils.keepDialogOnOrientationChanges(dialog); } } else if (requestCode == kActivityRequestCode_Settings) { // Return from activity settings. Update app behaviour if needed SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); boolean updatesEnabled = sharedPreferences.getBoolean("pref_updatesenabled", true); if (updatesEnabled) { mLatestCheckedDeviceAddress = null; mFirmwareUpdater.refreshSoftwareUpdatesDatabase(); } else { mFirmwareUpdater = null; } } }
From source file:org.hopestarter.wallet.ui.send.SendCoinsFragment.java
private void handleCancel() { if (state == null || state.compareTo(State.INPUT) <= 0) activity.setResult(Activity.RESULT_CANCELED); activity.finish(); }
From source file:com.github.gorbin.asne.googleplus.GooglePlusSocialNetwork.java
/** * Overrided for Google plus//w ww.ja v a 2s . c om * @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"). */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); int sanitizedRequestCode = requestCode % 0x10000; if (sanitizedRequestCode == REQUEST_AUTH) { if (resultCode == Activity.RESULT_OK && !googleApiClient.isConnected() && !googleApiClient.isConnecting()) { // This time, connect should succeed. googleApiClient.connect(); } else if (resultCode == Activity.RESULT_CANCELED) { if (mLocalListeners.get(REQUEST_LOGIN) != null) { mLocalListeners.get(REQUEST_LOGIN).onError(getID(), REQUEST_LOGIN, "canceled", null); } } } }
From source file:com.facebook.Session.java
/** * 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./*from w w w .j a v a2 s. c om*/ * * @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; }
From source file:com.ruesga.rview.fragments.EditorFragment.java
private void performCancelEdit() { AlertDialog dialog = new AlertDialog.Builder(getContext()).setTitle(R.string.change_edit_discard_title) .setMessage(R.string.change_edit_discard_message) .setPositiveButton(R.string.action_discard, (dialogInterface, i) -> { getActivity().setResult(Activity.RESULT_CANCELED); getActivity().finish();/* w w w. ja v a 2 s. co m*/ }).setNegativeButton(R.string.action_cancel, null).create(); dialog.show(); }
From source file:com.quarterfull.newsAndroid.NewsReaderListActivity.java
@Override public void onClick(ViewHolder vh, int position) { SharedPreferences mPrefs = PreferenceManager.getDefaultSharedPreferences(this); if (mPrefs.getBoolean(SettingsActivity.CB_SKIP_DETAILVIEW_AND_OPEN_BROWSER_DIRECTLY_STRING, false)) { String currentUrl = vh.getRssItem().getLink(); Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(currentUrl)); startActivity(browserIntent);/*from ww w . j ava 2s . c o m*/ ((NewsListRecyclerAdapter) getNewsReaderDetailFragment().getRecyclerView().getAdapter()) .ChangeReadStateOfItem(vh, true); } else { Intent intentNewsDetailAct = new Intent(this, NewsDetailActivity.class); intentNewsDetailAct.putExtra(NewsReaderListActivity.ITEM_ID, position); intentNewsDetailAct.putExtra(NewsReaderListActivity.TITEL, getNewsReaderDetailFragment().getTitel()); startActivityForResult(intentNewsDetailAct, Activity.RESULT_CANCELED); } }
From source file:org.akvo.caddisfly.sensor.colorimetry.liquid.ColorimetryLiquidActivity.java
@Override protected void onUserLeaveHint() { super.onUserLeaveHint(); releaseResources();/*from ww w . j a v a2 s. c om*/ if (alertDialogToBeDestroyed != null) { alertDialogToBeDestroyed.dismiss(); } setResult(Activity.RESULT_CANCELED); finish(); }
From source file:com.magestore.app.pos.SalesActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CheckoutListController.START_ACTIVITY_MUTIREADER) { if (resultCode == Activity.RESULT_OK) { String transaction_id = data.getStringExtra("transaction_id"); mCheckoutListController.doInputPlaceOrderWithPaypalHere(transaction_id); }/*from ww w. j a v a 2 s. c om*/ if (resultCode == Activity.RESULT_CANCELED) { mCheckoutListController.isShowLoadingDetail(false); String message = getString(R.string.paypal_cancel_order); DialogUtil.confirm(getContext(), message, R.string.done); } if (resultCode == MultiReaderConnectionActivity.TRANSACTION_ERRORS) { mCheckoutListController.isShowLoadingDetail(false); String message = getString(R.string.payment_error); DialogUtil.confirm(getContext(), message, R.string.done); } } }