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


C# Intent.SetAction方法代码示例

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


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

示例1: SendNotification

		private void SendNotification (Bundle data) {
			Intent intent;
			string type = data.GetString("type");

			intent = new Intent (this, typeof(MainActivity));
			if(type.Equals(PUSH_INVITE)) {
				ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId"));
				intent.SetAction(PUSH_INVITE);
			} else if(type.Equals(PUSH_EVENT_UPDATE)) {
				ViewController.getInstance().pushEventId = Convert.ToInt32(data.GetString("eventId"));
				intent.SetAction(PUSH_EVENT_UPDATE);
			} else if(type.Equals(PUSH_DELETE)) {
				//nothing else need to be done
				//MainActivity will refresh the events on start
			}

			intent.AddFlags (ActivityFlags.ClearTop);
			var pendingIntent = PendingIntent.GetActivity (this, 0, intent, PendingIntentFlags.OneShot);

			var notificationBuilder = new Notification.Builder(this)
				.SetSmallIcon (Resource.Drawable.pushnotification_icon)
				.SetContentTitle (data.GetString("title"))
				.SetContentText (data.GetString ("message"))
				.SetVibrate(new long[] {600, 600})
				.SetAutoCancel (true)
				.SetContentIntent (pendingIntent);

			var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
			notificationManager.Notify (notificationId, notificationBuilder.Build());
			notificationId++;
		}
开发者ID:Tucaen,项目名称:Karlsfeld-Volleyball-App,代码行数:31,代码来源:GcmListenerService.cs

示例2: OnReceive

 public override void OnReceive (Context context, Intent intent)
 {
     var serviceIntent = new Intent (context, typeof (WidgetStartStopService));
     serviceIntent.SetAction (intent.Action);
     serviceIntent.PutExtra (WidgetProvider.TimeEntryIdParameter, intent.GetStringExtra (WidgetProvider.TimeEntryIdParameter));
     StartWakefulService (context, serviceIntent);
 }
开发者ID:MrBloo63,项目名称:mobile,代码行数:7,代码来源:WidgetStartStopService.cs

示例3: EnableVoiceSynthesisEngine

 public void EnableVoiceSynthesisEngine()
 {
     Intent intent = new Intent();
     intent.SetAction("com.android.settings.TTS_SETTINGS");
     intent.SetFlags(ActivityFlags.NewTask);
     CurrentActivity.StartActivity(intent);
 }
开发者ID:india-rose,项目名称:xamarin-indiarose,代码行数:7,代码来源:InstallVoiceSynthesisService.cs

示例4: Stop

 public void Stop()
 {
     var context = Forms.Context.ApplicationContext;
     var intent = new Intent(context, typeof(StreamingService));
     intent.SetAction(StreamingService.ActionStop);
     Forms.Context.StartService(intent);
 }
开发者ID:MattHarrington,项目名称:XFStreamingAudio,代码行数:7,代码来源:AudioPlayerAndroid.cs

示例5: OnCreate

		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			var toggle_alarm_operation = new Intent (this, typeof(FindPhoneService));

			toggle_alarm_operation.SetAction(FindPhoneService.ACTION_TOGGLE_ALARM);
			var toggle_alarm_intent = PendingIntent.GetService (this, 0, toggle_alarm_operation, PendingIntentFlags.CancelCurrent);
			Android.App.Notification.Action alarm_action = new Android.App.Notification.Action (Resource.Drawable.alarm_action_icon, "", toggle_alarm_intent);
			var cancel_alarm_operation = new Intent (this, typeof(FindPhoneService));
			cancel_alarm_operation.SetAction (FindPhoneService.ACTION_CANCEL_ALARM);
			var cancel_alarm_intent = PendingIntent.GetService (this, 0, cancel_alarm_operation, PendingIntentFlags.CancelCurrent);
			var title = new SpannableString ("Find My Phone");
			title.SetSpan (new RelativeSizeSpan (0.85f), 0, title.Length(), SpanTypes.PointMark);
			notification = new Notification.Builder (this)
				.SetContentTitle (title)
				.SetContentText ("Tap to sound an alarm on phone")
				.SetSmallIcon (Resource.Drawable.ic_launcher)
				.SetVibrate (new long[]{ 0, 50 })
				.SetDeleteIntent (cancel_alarm_intent)
				.Extend (new Notification.WearableExtender ()
					.AddAction (alarm_action)
					.SetContentAction (0)
					.SetHintHideIcon (true))
				.SetLocalOnly (true)
				.SetPriority ((int)NotificationPriority.Max);
			((NotificationManager)GetSystemService (NotificationService))
				.Notify (FIND_PHONE_NOTIFICATION_ID, notification.Build ());

			Finish ();
		}
开发者ID:CHANDAN145,项目名称:monodroid-samples,代码行数:31,代码来源:MainActivity.cs

示例6: Start

        public override void Start()
        {
            Bundle hints = new Bundle();
            foreach (Symbology symbology in _enabled)
            {
                switch (symbology)
                {
                    case Symbology.UPCE: hints.PutBoolean(DO_UPCE, true); break;
                    case Symbology.EAN8: hints.PutBoolean(DO_EAN8, true); break;
                    case Symbology.EAN13: hints.PutBoolean(DO_EAN13, true); break;
                    case Symbology.Code39: hints.PutBoolean(DO_CODE93, true); break;
                    case Symbology.Code93: hints.PutBoolean(DO_CODE39, true); break;
                    case Symbology.Code128: hints.PutBoolean(DO_CODE128, true); break;
                    case Symbology.Sticky: hints.PutBoolean(DO_STICKY, true); break;

                    case Symbology.UPCA: break;
                    default: break;
                }
            }
            hints.PutString(DO_BROADCAST_TO, RedLaserScanReceiver.BROADCAST_ACTION);

            Intent i = new Intent();
            i.SetAction("com.target.redlasercontainer.SCAN");
            i.PutExtras(hints);

            Log.Info("BarcodeScanning", "broadcast intent with action com.target.redlasercontainter.SCAN sent");
            try
            {
                _context.SendBroadcast(i);
            }
            catch (Exception ex)
            {
                Log.Error("BarcodeScanning", ex.Message);
            }
        }
开发者ID:oduma,项目名称:Sciendo.Fitas.Droid,代码行数:35,代码来源:RedLaser.MD.cs

示例7: OnAttachClick

	    private void OnAttachClick(object sender, EventArgs e)
	    {
            var imageIntent = new Intent();
            imageIntent.SetType("image/*");
            imageIntent.SetAction(Intent.ActionGetContent);
            StartActivityForResult(Intent.CreateChooser(imageIntent, "Select a photo"), SelectPhotoId);
	    }
开发者ID:tamifist,项目名称:KinderChat,代码行数:7,代码来源:ConversationActivity.cs

示例8: OnActivityResult

        /// <summary>
        /// Process results from started activities.
        /// </summary>
        protected override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            if (requestCode == RECOGNIZER_RESULT && resultCode == RESULT_OK)
            {
                var matches = data.GetStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

                var speechText = FindViewById<TextView>(R.Ids.speechText);
                recognizedText = matches.Get(0);
                speechText.SetText(recognizedText);

                var checkIntent = new Intent();
                checkIntent.SetAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
                StartActivityForResult(checkIntent, SPEECH_RESULT);
            }

            if (requestCode == SPEECH_RESULT)
            {
                if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS)
                {
                    textToSpeech = new TextToSpeech(this, this);
                    textToSpeech.SetLanguage(Locale.US);
                }
                else
                {
                    // TTS data not yet loaded, try to install it
                    var ttsLoadIntent = new Intent();
                    ttsLoadIntent.SetAction(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
                    StartActivity(ttsLoadIntent);
                }
            }
            base.OnActivityResult(requestCode, resultCode, data);
        }
开发者ID:MahendrenGanesan,项目名称:samples,代码行数:35,代码来源:MainActivity.cs

示例9: btnProfileImage_Clicked

		void btnProfileImage_Clicked(object sender, EventArgs e)
		{
			var imageIntent = new Intent ();
			imageIntent.SetType ("image/jpeg");
			imageIntent.SetAction (Intent.ActionGetContent);
			StartActivityForResult (Intent.CreateChooser (imageIntent, "Select photo"), 0);
		}
开发者ID:JoshuaZane,项目名称:Android,代码行数:7,代码来源:RegisterUser.cs

示例10: ButtonOnClick

 private void ButtonOnClick(object sender, EventArgs eventArgs)
 {
     Intent = new Intent();
     Intent.SetType("image/*");
     Intent.SetAction(Intent.ActionGetContent);
     StartActivityForResult(Intent.CreateChooser(Intent, "Select Picture"), PickImageId);
 }
开发者ID:eduardoguilarducci,项目名称:recipes,代码行数:7,代码来源:Activity1.cs

示例11: OnCreate

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate {
                button.Text = string.Format("{0} clicks!", count++); };

            var file = fileFromAsset(this, "test.pdf");

            //var uri = Android.Net.Uri.FromFile(new File("file:///android_asset/test.pdf"));

            var uri = Android.Net.Uri.Parse(file.AbsolutePath);
            var intent = new Intent (this, typeof (MuPDFActivity));
            intent.SetFlags (ActivityFlags.NoHistory);
            intent.SetAction (Intent.ActionView);
            intent.SetData(uri);
            this.StartActivity(intent);
        }
开发者ID:SaberZA,项目名称:XamarinPdfTest,代码行数:25,代码来源:MainActivity.cs

示例12: getRemoveShortcutIntent

 public Intent getRemoveShortcutIntent(string name, Uri uri)
 {
     Intent i = new Intent();
     i.PutExtra(Intent.ExtraShortcutIntent, getNoteViewShortcutIntent(name, uri));
     i.PutExtra(Intent.ExtraShortcutName, name);
     i.SetAction("com.android.launcher.action.UNINSTALL_SHORTCUT");
     return i;
 }
开发者ID:decriptor,项目名称:tomdroid,代码行数:8,代码来源:NoteViewShortcutsHelper.cs

示例13: Scan

 public void Scan()
 {
     var intent = new Intent();
     Activity current = (Activity)Forms.Context;
     intent.SetAction(ACTION_SOFTSCANTRIGGER);
     intent.PutExtra(EXTRA_PARAM, DWAPI_TOGGLE_SCANNING);
     current.SendBroadcast(intent);
 }
开发者ID:pfmaggi,项目名称:Xam_BarcodeForms,代码行数:8,代码来源:BarcodeScanner.Droid.cs

示例14: Play

 public void Play(Uri source)
 {
     var context = Forms.Context.ApplicationContext;
     var intent = new Intent(context, typeof(StreamingService));
     intent.SetAction(StreamingService.ActionPlay);
     intent.PutExtra("source", source.AbsoluteUri);
     Forms.Context.StartService(intent);
 }
开发者ID:MattHarrington,项目名称:XFStreamingAudio,代码行数:8,代码来源:AudioPlayerAndroid.cs

示例15: ShareText

 public void ShareText(string text)
 {
   Intent sendIntent = new Intent();
   sendIntent.SetAction(Intent.ActionSend);
   sendIntent.PutExtra(Intent.ExtraText, text);
   sendIntent.SetType("text/plain");
   this.StartActivity(sendIntent);
 }
开发者ID:patridge,项目名称:Xamarin.Forms.Plugins,代码行数:8,代码来源:PhoneService.cs


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