protected override void OnHandleIntent (Android.Content.Intent intent) { var errorMessage = string.Empty; mReceiver = intent.GetParcelableExtra (Constants.Receiver) as ResultReceiver; if (mReceiver == null) { Log.Wtf (TAG, "No receiver received. There is nowhere to send the results."); return; } var location = intent.GetParcelableExtra (Constants.LocationDataExtra) as Location; if (location == null) { errorMessage = GetString (Resource.String.no_location_data_provided); Log.Wtf (TAG, errorMessage); DeliverResultToReceiver (Result.FirstUser, errorMessage); return; } var geocoder = new Geocoder (this, Java.Util.Locale.Default); List<Address> addresses = null; try { addresses = new List<Address> (geocoder.GetFromLocation (location.Latitude, location.Longitude, 1)); } catch (IOException ioException) { errorMessage = GetString (Resource.String.service_not_available); Log.Error (TAG, errorMessage, ioException); } catch (IllegalArgumentException illegalArgumentException) { errorMessage = GetString (Resource.String.invalid_lat_long_used); Log.Error (TAG, string.Format ("{0}. Latitude = {1}, Longitude = {2}", errorMessage, location.Latitude, location.Longitude), illegalArgumentException); } if (addresses == null || addresses.Count == 0) { if (string.IsNullOrEmpty (errorMessage)) { errorMessage = GetString (Resource.String.no_address_found); Log.Error (TAG, errorMessage); } DeliverResultToReceiver (Result.FirstUser, errorMessage); } else { var address = addresses.FirstOrDefault (); var addressFragments = new List<string> (); for (int i = 0; i < address.MaxAddressLineIndex; i++) { addressFragments.Add (address.GetAddressLine (i)); } Log.Info (TAG, GetString (Resource.String.address_found)); DeliverResultToReceiver (Result.Canceled, string.Join ("\n", addressFragments)); } }
protected override void OnActivityResult (int requestCode, Android.App.Result resultCode, Android.Content.Intent data) { // retrieve the error code, if available int errorCode = -1; if (data != null) { errorCode = data.GetIntExtra (WalletConstants.ExtraErrorCode, -1); } switch (requestCode) { case REQUEST_CODE_MASKED_WALLET: switch (resultCode) { case Android.App.Result.Ok: var maskedWallet = data.GetParcelableExtra (WalletConstants.ExtraMaskedWallet).JavaCast<MaskedWallet> (); launchConfirmationPage(maskedWallet); break; case Android.App.Result.Canceled: break; default: HandleError (errorCode); break; } break; case WalletConstants.ResultError: HandleError (errorCode); break; default: base.OnActivityResult (requestCode, resultCode, data); break; } }
protected override void OnActivityResult (int requestCode, Result resultCode, Android.Content.Intent data) { switch (requestCode) { case _pickSoundRequestId: if (resultCode == Result.Ok) { var uri = data.GetParcelableExtra (RingtoneManager.ExtraRingtonePickedUri); var ringtone = RingtoneManager.GetRingtone (this, Android.Net.Uri.Parse (uri.ToString ())); _soundPref.Summary = ringtone.GetTitle (this); PreferenceManager.GetDefaultSharedPreferences (this).Edit ().PutString (SoundSettingKey, uri.ToString ()).Commit (); GoogleAnalyticsManager.ReportEvent (GACategory.SettingsScreen, GAAction.Click, "new ringtone is set"); } break; default: if (_billingManager != null) _billingManager.OnActivityResult (requestCode, resultCode, data); base.OnActivityResult (requestCode, resultCode, data); break; } }
protected override void OnActivityResult (int requestCode, Android.App.Result resultCode, Android.Content.Intent data) { switch (requestCode) { case REQUEST_CODE_CHANGE_MASKED_WALLET: if (resultCode == Android.App.Result.Ok && data.HasExtra (WalletConstants.ExtraMaskedWallet)) { mMaskedWallet = data.GetParcelableExtra (WalletConstants.ExtraMaskedWallet).JavaCast<MaskedWallet> (); ((FullWalletConfirmationButtonFragment) ResultTargetFragment) .UpdateMaskedWallet (mMaskedWallet); } // you may also want to use the new masked wallet data here, say to recalculate // shipping or taxes if shipping address changed break; case WalletConstants.ResultError: int errorCode = data.GetIntExtra (WalletConstants.ExtraErrorCode, 0); HandleError (errorCode); break; default: base.OnActivityResult (requestCode, resultCode, data); break; } }
public override void OnActivityResult (int requestCode, int resultCode, Android.Content.Intent data) { mProgressDialog.Hide (); // retrieve the error code, if available int errorCode = -1; if (data != null) errorCode = data.GetIntExtra (WalletConstants.ExtraErrorCode, -1); switch (requestCode) { case REQUEST_CODE_RESOLVE_ERR: if (resultCode == (int)Result.Ok) { mGoogleApiClient.Connect(); } else { handleUnrecoverableGoogleWalletError(errorCode); } break; case REQUEST_CODE_RESOLVE_LOAD_FULL_WALLET: switch (resultCode) { case (int)Result.Ok: if (data.HasExtra(WalletConstants.ExtraFullWallet)) { FullWallet fullWallet = data.GetParcelableExtra (WalletConstants.ExtraFullWallet).JavaCast<FullWallet> (); // the full wallet can now be used to process the customer's payment // send the wallet info up to server to process, and to get the result // for sending a transaction status fetchTransactionStatus(fullWallet); } else if (data.HasExtra(WalletConstants.ExtraMaskedWallet)) { // re-launch the activity with new masked wallet information mMaskedWallet = data.GetParcelableExtra (WalletConstants.ExtraMaskedWallet).JavaCast<MaskedWallet> (); mActivityLaunchIntent.PutExtra (Constants.EXTRA_MASKED_WALLET, mMaskedWallet); StartActivity(mActivityLaunchIntent); } break; case (int)Result.Canceled: // nothing to do here break; default: handleError(errorCode); break; } break; } }
public void OnActivityResult(int requestCode, Result resultCode, Android.Content.Intent data) { if (requestCode == PayPalManager.REQUEST_CODE_PAYMENT) { if (resultCode == Result.Ok) { PaymentConfirmation confirm = (PaymentConfirmation)data.GetParcelableExtra (PaymentActivity.ExtraResultConfirmation); if (confirm != null) { try { System.Diagnostics.Debug.WriteLine (confirm.ToJSONObject ().ToString(4)); System.Diagnostics.Debug.WriteLine(confirm.Payment .ToJSONObject ().ToString (4)); /** * TODO: send 'confirm' (and possibly confirm.getPayment() to your server for verification * or consent completion. * See https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ * for more details. * * For sample mobile backend interactions, see * https://github.com/paypal/rest-api-sdk-python/tree/master/samples/mobile_backend */ Toast.MakeText ( Context.ApplicationContext, "PaymentConfirmation info received from PayPal", ToastLength.Short) .Show (); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine ("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Canceled) { System.Diagnostics.Debug.WriteLine ("The user canceled."); } else if ((int)resultCode == PaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine ( "An invalid Payment or PayPalConfiguration was submitted. Please see the docs."); } }else if (requestCode == REQUEST_CODE_FUTURE_PAYMENT) { if (resultCode == Result.Ok) { PayPalAuthorization auth = data.GetParcelableExtra (PayPalFuturePaymentActivity.ExtraResultAuthorization); if (auth != null) { try { System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4)); String authorization_code = auth.AuthorizationCode; System.Diagnostics.Debug.WriteLine(authorization_code); sendAuthorizationToServer(auth); Toast.MakeText( Context.ApplicationContext, "Future Payment code received from PayPal", ToastLength.Long) .Show(); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine ("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Ok) { System.Diagnostics.Debug.WriteLine ("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine ( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } else if (requestCode == REQUEST_CODE_PROFILE_SHARING) { if (resultCode == Result.Ok) { PayPalAuthorization auth = data.GetParcelableExtra (PayPalProfileSharingActivity.ExtraResultAuthorization); if (auth != null) { try { System.Diagnostics.Debug.WriteLine(auth.ToJSONObject().ToString(4)); String authorization_code = auth.AuthorizationCode; System.Diagnostics.Debug.WriteLine(authorization_code); sendAuthorizationToServer(auth); Toast.MakeText( Context.ApplicationContext, "Profile Sharing code received from PayPal", ToastLength.Short) .Show(); } catch (JSONException e) { System.Diagnostics.Debug.WriteLine ("an extremely unlikely failure occurred: " + e.Message); } } } else if (resultCode == Result.Canceled) { System.Diagnostics.Debug.WriteLine ("The user canceled."); } else if ((int)resultCode == PayPalFuturePaymentActivity.ResultExtrasInvalid) { System.Diagnostics.Debug.WriteLine( "Probably the attempt to previously start the PayPalService had an invalid PayPalConfiguration. Please see the docs."); } } }