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


C# Intent.GetBooleanExtra方法代码示例

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


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

示例1: OnStartCommand

        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            AndroidSensusServiceHelper serviceHelper = SensusServiceHelper.Get() as AndroidSensusServiceHelper;

            serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ").", LoggingLevel.Normal, GetType());

            serviceHelper.MainActivityWillBeDisplayed = intent.GetBooleanExtra(AndroidSensusServiceHelper.MAIN_ACTIVITY_WILL_BE_DISPLAYED, false);

            // the service can be stopped without destroying the service object. in such cases, 
            // subsequent calls to start the service will not call OnCreate. therefore, it's 
            // important that any code called here is okay to call multiple times, even if the 
            // service is running. calling this when the service is running can happen because 
            // sensus receives a signal on device boot and for any callback alarms that are 
            // requested. furthermore, all calls here should be nonblocking / async so we don't 
            // tie up the UI thread.

            serviceHelper.StartAsync(() =>
                {
                    if (intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_KEY, false))
                    {
                        string callbackId = intent.GetStringExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_ID_KEY);
                        if (callbackId != null)
                        {
                            bool repeating = intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false);
                            serviceHelper.RaiseCallbackAsync(callbackId, repeating, true);
                        }
                    }
                });

            return StartCommandResult.RedeliverIntent;
        }
开发者ID:shamik94,项目名称:sensus,代码行数:31,代码来源:AndroidSensusService.cs

示例2: OnStartCommand

        public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
        {
            _serviceHelper.Logger.Log("Sensus service received start command (startId=" + startId + ").", LoggingLevel.Debug, GetType());

            _serviceHelper.MainActivityWillBeSet = intent.GetBooleanExtra(AndroidSensusServiceHelper.MAIN_ACTIVITY_WILL_BE_SET, false);

            // the service can be stopped without destroying the service object. in such cases,
            // subsequent calls to start the service will not call OnCreate, which is why the
            // following code needs to run here -- e.g., starting the helper object and displaying
            // the notification. therefore, it's important that any code called here is
            // okay to call multiple times, even if the service is running. calling this when
            // the service is running can happen because sensus receives a signal on device
            // boot and for any callback alarms that are requested. furthermore, all calls here
            // should be nonblocking / async so we don't tie up the UI thread.

            _serviceHelper.StartAsync(() =>
                {
                    if (intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_KEY, false))
                    {
                        string callbackId = intent.GetStringExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_ID_KEY);
                        if (callbackId != null)
                        {
                            bool repeating = intent.GetBooleanExtra(AndroidSensusServiceHelper.SENSUS_CALLBACK_REPEATING_KEY, false);
                            _serviceHelper.RaiseCallbackAsync(callbackId, repeating, true);
                        }
                    }
                });

            return StartCommandResult.RedeliverIntent;
        }
开发者ID:trishalaneeraj,项目名称:sensus,代码行数:30,代码来源:AndroidSensusService.cs

示例3: 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

示例4: OnReceive

            public override void OnReceive (Context context, Intent intent)
            {
                var extraDevice = intent.GetParcelableExtra(UsbManager.ExtraDevice) as UsbDevice;
                if (device.DeviceName != extraDevice.DeviceName)
                    return;

                var permissionGranted = intent.GetBooleanExtra (UsbManager.ExtraPermissionGranted, false);
                observer.OnNext (permissionGranted);
                observer.OnCompleted ();
            }
开发者ID:reactiveui,项目名称:ReactiveUI,代码行数:10,代码来源:UsbManagerExtensions.cs

示例5: OnActivityResult

 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     base.OnActivityResult(requestCode, resultCode, data);
     Console.WriteLine("OnActivityResult(...) called");
     if (data == null)
         return;
     if (resultCode == Result.Ok) {
         mQuestionBank[mCurrentIndex].DidCheat = data.GetBooleanExtra(CheatActivity.EXTRA_ANSWER_SHOWN, false);
     }
 }
开发者ID:yingfangdu,项目名称:BNR,代码行数:10,代码来源:QuizActivity.cs

示例6: OnReceive

    /// <summary>
    /// Received a notification via BR.
    /// </summary>
    /// <param name="context"></param>
    /// <param name="intent"></param>
    public override void OnReceive(Context context, Intent intent)
    {
      if (intent.Action != ConnectivityManager.ConnectivityAction)
        return;

      var noConnectivity = intent.GetBooleanExtra(ConnectivityManager.ExtraNoConnectivity, false);

      if (ConnectionChanged == null)
        return;

      ConnectionChanged(new ConnectivityChangedEventArgs { IsConnected = !noConnectivity });
    }
开发者ID:Lotpath,项目名称:Xamarin.Plugins,代码行数:17,代码来源:ConnectivityChangeBroadcastReceiver.cs

示例7: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			var ok = intent.GetBooleanExtra ("ok", false);
			var id = intent.GetStringExtra ("id");
			JobResult result;
			if (_Jobs != null && _Jobs.TryGetValue (id, out result)) {
				result.IsRunning = false;
				result.JobID = id;
				result.HasError = !ok;
				_Jobs.TryUpdate (id, result, result);
			}
		}
开发者ID:ddomengeaux,项目名称:xamarin-amccorma,代码行数:12,代码来源:DroidTasks.cs

示例8: OnHandleIntent

 protected override void OnHandleIntent(Intent intent)
 {
     bool isEntering= intent.GetBooleanExtra(LocationManager.KeyProximityEntering, false);
     NotificationCompat.Builder builder = new NotificationCompat.Builder (this);
     var notification = builder
         .SetContentTitle("TODO")
         .SetContentText((isEntering? "Entering" : "Exiting") + " fence")
         .Build();
     var notificationService = (NotificationManager)GetSystemService (Context.NotificationService);
     notificationService.Notify (1, notification);
     int i = 17;
     //TODO: check LocationManager.KEY_PROXIMITY
 }
开发者ID:phamthangnd,项目名称:TIG-CrossPlatformMobile,代码行数:13,代码来源:GeofenceIntentService.cs

示例9: OnStartCommand

 public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId)
 {
     bool playing = intent.GetBooleanExtra("playing", false);
     if (playing)
     {
         mp.Start();
     }
     else
     {
         mp.Pause();
     }
     return base.OnStartCommand(intent, flags, startId);
 }
开发者ID:i-1213,项目名称:Game,代码行数:13,代码来源:SoundService.cs

示例10: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            String key = LocationManager.KeyProximityEntering;
            Boolean entering = intent.GetBooleanExtra (key, false);

            //latText = activity.FindViewById<TextView> (Resource.Id.textNotify);

            if (entering) {
                notifyUser ("Region Entered", location);
                //System.Console.WriteLine (">>>>>>>>>>>>>>>>REGION ENTERED!!!!!!!!<<<<<<<<<<<" + location);
            } else {
                //Do not notify the user.
            }
        }
开发者ID:toddreazor,项目名称:xba,代码行数:14,代码来源:ProximityIntentReceiver.cs

示例11: OnActivityResult

 protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
 {
     if ((requestCode == 1) && (resultCode == Result.Ok))
     {
         if (data.GetBooleanExtra("parkdeleted", false))
         {
             Finish();
         }
     }
     else
     {
         base.OnActivityResult(requestCode, resultCode, data);
     }
 }
开发者ID:m3mo89,项目名称:NationalParks,代码行数:14,代码来源:DetailActivity.cs

示例12: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			
			
			if (notificationManager == null)
				notificationManager = (NotificationManager) context.GetSystemService (Context.NotificationService);
			Bundle bundle = intent.Extras;
			Log.Debug (TAG,"[CustomJPushReceiver] onReceive - "+intent.Action +",extrals:"+ printBundle(bundle));

			if (JPushInterface.ActionRegistrationId.Equals (intent.Action)) {
				//注册成功,获取广播中的registerid
				var regId = bundle.GetString(JPushInterface.ExtraRegistrationId);
				Log.Debug(TAG, "[CustomJPushReceiver] 接收Registration Id : " + regId);
			    
			}
			else if (JPushInterface.ActionMessageReceived.Equals (intent.Action)) {
				//接收自定义消息
				Log.Debug(TAG, "[CustomJPushReceiver] 接收到推送下来的自定义消息: " + bundle.GetString(JPushInterface.ExtraMessage));
				ProcessCustomMessage(context, bundle);
				
			} else if (JPushInterface.ActionNotificationReceived.Equals (intent.Action)) {
				//接收到用户通知
				int notifactionId = bundle.GetInt(JPushInterface.ExtraNotificationId);
				Log.Debug(TAG, "[CustomJPushReceiver] 接收到推送下来的通知的ID: " + notifactionId);

			} else if (JPushInterface.ActionNotificationOpened.Equals (intent.Action)) {

				Log.Debug(TAG, "[CustomJPushReceiver] 用户点击打开了通知");
				OpenNotification (context,bundle);

			} else if (JPushInterface.ActionRichpushCallback.Equals (intent.Action)) {
				Log.Debug(TAG, "[CustomJPushReceiver] 用户收到到RICH PUSH CALLBACK: " + bundle.GetString(JPushInterface.ExtraExtra));
				//在这里根据 JPushInterface.EXTRA_EXTRA 的内容处理代码,比如打开新的Activity, 打开一个网页等..

			} else if (JPushInterface.ActionConnectionChange.Equals (intent.Action)) {
				//接收网络变化 连接/断开
				var connected = intent.GetBooleanExtra(JPushInterface.ExtraConnectionChange, false);
				Log.Warn(TAG, "[CustomJPushReceiver]" + intent.Action +" connected state change to "+connected);
			} else {
				//处理其它意图
				Log.Debug(TAG, "Unhandled intent - " + intent.Action);
			}
				

		}
开发者ID:lq-ever,项目名称:CommunityCenter,代码行数:45,代码来源:CustomJPushReceiver.cs

示例13: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            sqlite3_shutdown();
            SqliteConnection.SetConfig(SQLiteConfig.Serialized);
            sqlite3_initialize();

            // If you got a location extra, use it
            Location loc = (Location)intent.GetParcelableExtra(LocationManager.KeyLocationChanged);
            if (loc != null) {
                OnLocationReceived(context, loc);
                return;
            }
            // If you get here, something else has happened
            if (intent.HasExtra(LocationManager.KeyProviderEnabled)) {
                bool enabled = intent.GetBooleanExtra(LocationManager.KeyProviderEnabled, false);
                OnProviderEnabledChanged(context, enabled);
            }
        }
开发者ID:yingfangdu,项目名称:BNR,代码行数:18,代码来源:LocationReceiver.cs

示例14: finishLogin

        public void finishLogin(Intent intent)
        {
            System.Console.WriteLine ("finishLogin");
            String accountName = intent.GetStringExtra(AccountManager.KeyAccountName);
            String accountPassword = intent.GetStringExtra("password");
            Account account = new Account (accountName, "com.SnapAndGo.auth");

            CurrentAccount.account = account;

            String authtoken = intent.GetStringExtra (AccountManager.KeyAuthtoken);
            CurrentAccount.authToken = authtoken;

            if (!System.String.IsNullOrEmpty(authtoken)) {

                if (intent.GetBooleanExtra("isAddingNewAccount", true)) {

                    System.Console.WriteLine ("finishLogin: is adding a new account");

                    String authtokenType = "com.SnapAndGo.auth";

                    // Creating the account on the device and setting the auth token we got
                    // (Not setting the auth token will cause another call to the server to authenticate the user)

                    mAccountManager.AddAccountExplicitly(account, accountPassword, null);
                    mAccountManager.SetAuthToken(account, authtokenType, authtoken);
                } else {

                    System.Console.WriteLine ("finishLogin: is not adding a new account");

                    mAccountManager.SetPassword(account, accountPassword);
                }

                SetAccountAuthenticatorResult(intent.Extras);
                SetResult(Result.Ok, intent);

                Intent evexIntent = new Intent(this, typeof(EventsExplorerActivity));
                evexIntent.PutExtra("authToken", authtoken);
                StartActivity (evexIntent);
            } else {
                Toast.MakeText(Application.Context, "Username/Password is incorrect.",ToastLength.Long).Show();
            }
        }
开发者ID:ryanerdmann,项目名称:angora,代码行数:42,代码来源:LoginActivity.cs

示例15: OnReceive

		public override void OnReceive(Context context, Intent intent) {
			Log.Info(logTag, "Received intent: " + intent);
			String action = intent.Action;

			if (action == PushManager.ActionPushReceived) {

				int id = intent.GetIntExtra(PushManager.ExtraNotificationId, 0);

				Log.Info(logTag, "Received push notification. Alert: "
				      + intent.GetStringExtra(PushManager.ExtraAlert)
				      + " [NotificationID="+id+"]");

				LogPushExtras(intent);

			} else if (action == PushManager.ActionNotificationOpened) {

				Log.Info(logTag, "User clicked notification. Message: " + intent.GetStringExtra(PushManager.ExtraAlert));

				LogPushExtras(intent);

				Intent launch = new Intent (Intent.ActionMain);
				launch.SetClass(UAirship.Shared().ApplicationContext, typeof (MainActivity));
				launch.SetFlags (ActivityFlags.NewTask);

				UAirship.Shared().ApplicationContext.StartActivity(launch);

			} else if (action == PushManager.ActionRegistrationFinished) {
				Log.Info(logTag, "Registration complete. APID:" + intent.GetStringExtra(PushManager.ExtraApid)
				      + ". Valid: " + intent.GetBooleanExtra(PushManager.ExtraRegistrationValid, false));

				// Notify any app-specific listeners
				Intent launch = new Intent(UAirship.PackageName + APID_UPDATED_ACTION_SUFFIX);
				UAirship.Shared().ApplicationContext.SendBroadcast(launch);

			} else if (action == GCMMessageHandler.ActionGcmDeletedMessages) {
				Log.Info(logTag, "The GCM service deleted "+intent.GetStringExtra(GCMMessageHandler.ExtraGcmTotalDeleted)+" messages.");
			}

		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:39,代码来源:IntentReceiver.cs


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