当前位置: 首页>>代码示例>>C#>>正文


C# Android.GetParcelableExtra方法代码示例

本文整理汇总了C#中Android.GetParcelableExtra方法的典型用法代码示例。如果您正苦于以下问题:C# Android.GetParcelableExtra方法的具体用法?C# Android.GetParcelableExtra怎么用?C# Android.GetParcelableExtra使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android的用法示例。


在下文中一共展示了Android.GetParcelableExtra方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnHandleIntent

		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));
			}
		}
开发者ID:jingyul,项目名称:monodroid-samples,代码行数:52,代码来源:FetchAddressIntentService.cs

示例2: OnActivityResult

 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;
     }
 }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:29,代码来源:CheckoutActivity.cs

示例3: OnActivityResult

		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;
			}
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:22,代码来源:SettingsScreen.cs

示例4: OnActivityResult

 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;
     }
 }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:22,代码来源:ConfirmationActivity.cs

示例5: OnActivityResult

        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;
            }
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:45,代码来源:FullWalletConfirmationButtonFragment.cs

示例6: OnActivityResult

		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.");
				}
			}
		}
开发者ID:15mgm15,项目名称:PayPal.Forms,代码行数:90,代码来源:PayPalManager.cs


注:本文中的Android.GetParcelableExtra方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。