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


C# Intent.GetIntExtra方法代码示例

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


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

示例1: OnReceive

		public override void OnReceive(Context context, Intent intent)
		{
			if (!MainActivity.REPLY_ACTION.Equals(intent.Action))
				return;


			var requestId = intent.GetIntExtra(MainActivity.REQUEST_CODE_KEY, -1);
			if (requestId == -1)
				return;

			var reply = GetMessageText(intent);
			using (var notificationManager = NotificationManagerCompat.From(context))
			{
				// Create new notification to display, or re-build existing conversation to update with new response
				var notificationBuilder = new NotificationCompat.Builder(context);
				notificationBuilder.SetSmallIcon(Resource.Drawable.reply);
				notificationBuilder.SetContentText(Application.Context.GetString(Resource.String.replied));
				var repliedNotification = notificationBuilder.Build();


				// Call notify to stop progress spinner. 
				notificationManager.Notify(requestId, repliedNotification);
			}

			Toast.MakeText(context, $"Message sent: {reply}", ToastLength.Long).Show();
		}
开发者ID:xamarin,项目名称:monodroid-samples,代码行数:26,代码来源:MessageReplyReceiver.cs

示例2: main

		public static int main(Intent i){
			switch (i.GetIntExtra("previous",3)) { // This value shows which is the previous activity, with: 0-MainActivity/1-VertexActivity/2-EdgeActivity/3-Any other
			case 0:
				initiate(i);
				break;
			case 1:
				switch (graph.addVertex(i.GetStringExtra("vertex"))) {
				case -1:
					return 1;
				case -2:
					return 6;
				default:
					return 2;
				}
			case 2:
				switch (graph.addEdge(i.GetIntExtra("weight", -1),i.GetStringExtra("start"),i.GetStringExtra("end"))){
				case -1:
					return 1;
				case -2:
					return 3;
				case -3:
					return 4;
				case -4:
					return 7; //Do not accept weight 0
				default:
					return 5;
				}
			}
			return 0;
		}
开发者ID:gutoomota,项目名称:GraphApp.Xamarin,代码行数:30,代码来源:Controller.cs

示例3: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            var level = intent.GetIntExtra(BatteryManager.ExtraLevel, -1);
            var scale = intent.GetIntExtra(BatteryManager.ExtraScale, -1);

            var batteryPct = level / (float)scale;

            _batteryLevel.Text = string.Format("{000} %", batteryPct * 100);
            _batteryHealth.Text = ((BatteryHealth)intent.GetIntExtra(BatteryManager.ExtraHealth, 0)).ToString();
            _batteryTemp.Text = string.Format("{0:0.00} C", intent.GetIntExtra(BatteryManager.ExtraTemperature, 0) / 10.0);
            _batteryVoltage.Text = intent.GetIntExtra(BatteryManager.ExtraVoltage, 0) + " mV";
        }
开发者ID:Cheesebaron,项目名称:BatteryDrainer,代码行数:12,代码来源:BatteryReceiver.cs

示例4: OnHandleIntent

		protected override void OnHandleIntent (Intent intent)
		{
			google_api_client.BlockingConnect (TIME_OUT_MS, TimeUnit.Milliseconds);
			Android.Net.Uri dataItemUri = intent.Data;
			if (!google_api_client.IsConnected) {
				Log.Error (TAG, "Failed to update data item " + dataItemUri +
				" because client is disconnected from Google Play Services");
				return;
			}
			var dataItemResult = WearableClass.DataApi.GetDataItem (
				google_api_client, dataItemUri).Await ().JavaCast<IDataApiDataItemResult> ();

			var putDataMapRequest = PutDataMapRequest.CreateFromDataMapItem (
				DataMapItem.FromDataItem (dataItemResult.DataItem));
			var dataMap = putDataMapRequest.DataMap;

			//update quiz status variables
			int questionIndex = intent.GetIntExtra (EXTRA_QUESTION_INDEX, -1);
			bool chosenAnswerCorrect = intent.GetBooleanExtra (EXTRA_QUESTION_CORRECT, false);
			dataMap.PutInt (Constants.QUESTION_INDEX, questionIndex);
			dataMap.PutBoolean (Constants.CHOSEN_ANSWER_CORRECT, chosenAnswerCorrect);
			dataMap.PutBoolean (Constants.QUESTION_WAS_ANSWERED, true);
			PutDataRequest request = putDataMapRequest.AsPutDataRequest ();
			WearableClass.DataApi.PutDataItem (google_api_client, request).Await ();

			//remove this question notification
			((NotificationManager)GetSystemService (NotificationService)).Cancel (questionIndex);
			google_api_client.Disconnect ();
		}
开发者ID:WalterVale,项目名称:monodroid-samples,代码行数:29,代码来源:UpdateQuestionService.cs

示例5: OnReceive

 public override void OnReceive(Context context, Intent intent)
 {
     string action = intent.Action;
     if (WifiP2pManager.WifiP2pStateChangedAction == action)
     {
         // Determine if Wifi Direct mode is enabled
         int state = intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pStateChangedAction - state: {0}", state);
         if (state == (int)WifiP2pState.Enabled)
         {
             // enabled
         }
         else
         {
             // disabled
         }
     }
     else if (WifiP2pManager.WifiP2pPeersChangedAction == action)
     {
         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pPeersChangedAction");
         _manager.RequestPeers(_channel, _peerListListener);
     }
     else if (WifiP2pManager.WifiP2pConnectionChangedAction == action)
     {
         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pConnectionChangedAction");
     }
     else if (WifiP2pManager.WifiP2pThisDeviceChangedAction == action)
     {
         Console.WriteLine(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> WifiDirectReceiver - OnReceive - WifiP2pThisDeviceChangedAction");
     }
 }
开发者ID:pascalfr,项目名称:MPfm,代码行数:31,代码来源:WifiDirectReceiver.cs

示例6: CompleteWakefulIntent

    /// <summary>
    /// Finish the execution from previous <see cref="StartWakefulService(Context, Intent)"/>.
    /// </summary>
    /// <remarks>
    /// Any wake lock that was being held will now be released.
    /// </remarks>
    /// <param name="intent">The <see cref="Intent"/> that was originally generated by <see cref="StartWakefulService(Context, Intent)"/></param>
    /// <returns><c>true</c> if the intent is associated with a wake lock that is now released.
    /// Returns <c>false</c> if there was no wake lock specified for it.</returns>
    internal static bool CompleteWakefulIntent(Intent intent) {
      int id = intent.GetIntExtra(ExtraWakeLockId, 0);
      if (id == 0) {
        return false;
      }

      lock (activeWakeLocksMutex) {
        PowerManager.WakeLock wl = activeWakeLocks[id];
        if (wl != null) {
          wl.Release();
          activeWakeLocks.Remove(id);

          return true;
        }

        // We return true whether or not we actually found the wake lock
        // the return code is defined to indicate whether the Intent contained
        // an identifier for a wake lock that it was supposed to match.
        // We just log a warning here if there is no wake lock found, which could
        // happen for example if this function is called twice on the same
        // intent or the process is killed and restarted before processing the intent.
        Android.Util.Log.Warn("ParseWakefulHelper", "No active wake lock id #" + id);
        return true;
      }
    }
开发者ID:mehul9595,项目名称:Parse-SDK-dotNET,代码行数:34,代码来源:ParseWakefulHelper.cs

示例7: OnCreate

        public override void OnCreate (Android.OS.Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);
        
            if (savedInstanceState != null) {
                mRetryCounter = savedInstanceState.GetInt (KEY_RETRY_COUNTER);
                mRetryLoadFullWalletCount = savedInstanceState.GetInt (KEY_RETRY_FULL_WALLET_COUNTER);
                mHandleFullWalletWhenReady =
                    savedInstanceState.GetBoolean (KEY_HANDLE_FULL_WALLET_WHEN_READY);
            }
            mActivityLaunchIntent = Activity.Intent;
            mItemId = mActivityLaunchIntent.GetIntExtra (Constants.EXTRA_ITEM_ID, 0);
            mMaskedWallet = mActivityLaunchIntent.GetParcelableExtra (Constants.EXTRA_MASKED_WALLET).JavaCast<MaskedWallet> ();

            var accountName = ((BikestoreApplication) Activity.Application).AccountName;

            // Set up an API client;
            mGoogleApiClient = new GoogleApiClient.Builder (Activity)
                .AddConnectionCallbacks (this)
                .AddOnConnectionFailedListener (this)
                .SetAccountName (accountName)
                .AddApi (WalletClass.API, new WalletClass.WalletOptions.Builder ()
                    .SetEnvironment (Constants.WALLET_ENVIRONMENT)
                    .SetTheme (WalletConstants.ThemeLight)
                    .Build ())
                .Build ();

            mRetryHandler = new RetryHandler (this);
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:29,代码来源:FullWalletConfirmationButtonFragment.cs

示例8: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            var action = intent.Action;

            switch (action)
            {
                case WifiP2pManager.WifiP2pStateChangedAction:
                    WifiP2pState state = (WifiP2pState)intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
                    P2PManager.Available = state == WifiP2pState.Enabled;
                    break;
                case WifiP2pManager.WifiP2pPeersChangedAction:
                    manager.RequestPeers(channel, new PeerListListener(peerList =>
                    {
                        P2PManager.peerList = peerList.DeviceList;
                        P2PManager.waitForPeerListSuccess = true;
                        P2PManager.waitForPeerList.Set();
                    }));
                    break;
                case WifiP2pManager.WifiP2pConnectionChangedAction:

                    break;
                case WifiP2pManager.WifiP2pThisDeviceChangedAction:

                    break;
            }
        }
开发者ID:fubar-coder,项目名称:cryptrans,代码行数:26,代码来源:WiFiDirectBroadcastReceiver.cs

示例9: OnActivityResult

 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     if (resultCode == Result.Ok)
         if (requestCode==tkey)
         {
             EditText tb1 = FindViewById<EditText>(Resource.Id.text);
             tb1.Text = File.ReadAllText(data.GetStringExtra("1"));
             Log.Verbose("FileListFragment", "файл {0} был открыт.", data.GetStringExtra("1"));
             Toast.MakeText(this, "файл выбран" + data.GetStringExtra("1"), ToastLength.Short).Show();
         }
         else
         {
             ttslist[data.GetIntExtra("4",0)] = new elemTts(data.GetStringExtra("1"), data.GetIntExtra("2",0) / 255f + 0.1f,data.GetIntExtra("3",0) / 170f + 0.5f);
         }
 }
开发者ID:dariadr,项目名称:TextToSpeach,代码行数:16,代码来源:MainActivity.cs

示例10: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            var message = new SmsMessage {
                Text = intent.GetStringExtra ("messageText"),
                SmsGroupId = intent.GetIntExtra ("smsGroupId", -1),
                ContactAddressBookId = intent.GetStringExtra ("addressBookId"),
                ContactName = intent.GetStringExtra ("contactName"),
                SentDate = DateTime.Parse (intent.GetStringExtra ("dateSent"))
            };

            switch ((int)ResultCode)
            {
                case (int)Result.Ok:
                    _messageRepo = new Repository<SmsMessage>();
                    _messageRepo.Save (message);
                    Toast.MakeText (context, string.Format ("Message sent to {0}", message.ContactName), ToastLength.Short).Show ();
                    break;
                case (int)global::Android.Telephony.SmsResultError.NoService:
                case (int)global::Android.Telephony.SmsResultError.RadioOff:
                case (int)global::Android.Telephony.SmsResultError.NullPdu:
                case (int)global::Android.Telephony.SmsResultError.GenericFailure:
                default:
                    Toast.MakeText (context, string.Format("Doh! Message could not be sent to {0}.", message.ContactName),
                                ToastLength.Short).Show ();
                    break;
            }
            _messageRepo = null;
        }
开发者ID:jheerman,项目名称:Prattle,代码行数:28,代码来源:PrattleSmsReceiver.cs

示例11: OnReceive

 /// <summary>
 /// This is the entry point for all asynchronous messages sent from Android Market to
 /// the application. This method forwards the messages on to the
 /// <seealso cref="BillingService"/>, which handles the communication back to Android Market.
 /// The <seealso cref="BillingService"/> also reports state changes back to the application through
 /// the <seealso cref="ResponseHandler"/>.
 /// </summary>
 public override void OnReceive(Context context, Intent intent)
 {
     string action = intent.Action;
     if (Consts.ACTION_PURCHASE_STATE_CHANGED.Equals(action))
     {
         string signedData = intent.GetStringExtra(Consts.INAPP_SIGNED_DATA);
         string signature = intent.GetStringExtra(Consts.INAPP_SIGNATURE);
         purchaseStateChanged(context, signedData, signature);
     }
     else if (Consts.ACTION_NOTIFY.Equals(action))
     {
         string notifyId = intent.GetStringExtra(Consts.NOTIFICATION_ID);
         if (Consts.DEBUG)
         {
             Log.Info(TAG, "notifyId: " + notifyId);
         }
         notify(context, notifyId);
     }
     else if (Consts.ACTION_RESPONSE_CODE.Equals(action))
     {
         long requestId = intent.GetLongExtra(Consts.INAPP_REQUEST_ID, -1);
         int responseCodeIndex = intent.GetIntExtra(Consts.INAPP_RESPONSE_CODE, (int)Consts.ResponseCode.RESULT_ERROR);
         checkResponseCode(context, requestId, responseCodeIndex);
     }
     else
     {
         Log.Warn(TAG, "unexpected action: " + action);
     }
 }
开发者ID:Ezekoka,项目名称:MonoGame-StarterKits,代码行数:36,代码来源:BillingReceiver.cs

示例12: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            var action = intent.Action;

            if (WifiP2pManager.WifiP2pStateChangedAction.Equals(action))
            {
                // UI update to indicate wifi p2p status.
                var state = intent.GetIntExtra(WifiP2pManager.ExtraWifiState, -1);
                if (state == (int) WifiP2pState.Enabled)
                    // Wifi Direct mode is enabled
                    _activity.IsWifiP2PEnabled = true;
                else
                {
                    _activity.IsWifiP2PEnabled = false;
                    _activity.ResetData();
                }
                Log.Debug(WiFiDirectActivity.Tag, "P2P state changed - " + state);
            }
            else if (WifiP2pManager.WifiP2pPeersChangedAction.Equals(action))
            {
                // request available peers from the wifi p2p manager. This is an
                // asynchronous call and the calling activity is notified with a
                // callback on PeerListListener.onPeersAvailable()
                if (_manager != null)
                {
                    _manager.RequestPeers(_channel,
                                          _activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list));
                }
                Log.Debug(WiFiDirectActivity.Tag, "P2P peers changed");
            }
            else if (WifiP2pManager.WifiP2pConnectionChangedAction.Equals(action))
            {
                if (_manager == null)
                    return;

                var networkInfo = (NetworkInfo) intent.GetParcelableExtra(WifiP2pManager.ExtraNetworkInfo);

                if (networkInfo.IsConnected)
                {
                    // we are connected with the other device, request connection
                    // info to find group owner IP

                    var fragment =
                        _activity.FragmentManager.FindFragmentById<DeviceDetailFragment>(Resource.Id.frag_detail);
                    _manager.RequestConnectionInfo(_channel, fragment);
                }
                else
                {
                    // It's a disconnect
                    _activity.ResetData();
                }
            }
            else if (WifiP2pManager.WifiP2pThisDeviceChangedAction.Equals(action))
            {
                var fragment =
                        _activity.FragmentManager.FindFragmentById<DeviceListFragment>(Resource.Id.frag_list);
                fragment.UpdateThisDevice((WifiP2pDevice)intent.GetParcelableExtra(WifiP2pManager.ExtraWifiP2pDevice));
            }
        }
开发者ID:pacificIT,项目名称:WiFiDirectSample,代码行数:59,代码来源:WiFiDirectBroadcastReceiver.cs

示例13: GetRecipeId

		public static int? GetRecipeId(Intent intent) {
			var recipeId = intent.GetIntExtra(RecipeId, -1);
			if(recipeId != -1) {
				return recipeId;
			}

			return null;
		}
开发者ID:bernhardkircher,项目名称:cookr.xamarin,代码行数:8,代码来源:ActivityParameters.cs

示例14: GetAlbum

        public static Album GetAlbum (DrunkAudibleMobileDatabase database, Intent intent)
        {
            var album = database
                    .Albums
                    .FirstOrDefault (a => a.Id == intent.GetIntExtra (ALBUM_ID_INTENT_EXTRA, -1));

            return album ?? Album.Empty;
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:8,代码来源:ExtraUtils.cs

示例15: OnReceive

             public override void OnReceive(Context context, Intent intent) {
                    if (intent.Action.Equals(ACTION_STARTED)) {
                        callbackData.Text = ("STARTED");
                    } else if (intent.Action.Equals(ACTION_UPDATE)) {
                        callbackData.Text = ("Got update: " + intent.GetIntExtra("value", 0));
                    } else if (intent.Action.Equals(ACTION_STOPPED)) {
                        callbackData.Text = ("STOPPED");
					}
                }
开发者ID:Xtremrules,项目名称:dot42,代码行数:9,代码来源:LocalServiceBroadcaster.cs


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