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


C# Intent.GetStringExtra方法代码示例

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


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

示例1: HandleRegistration

		protected async void HandleRegistration(Context context, Intent intent)
		{
			string registrationId = intent.GetStringExtra("registration_id");
			string error = intent.GetStringExtra("error");
			string unregistration = intent.GetStringExtra("unregistered");

			var nMgr = (NotificationManager)GetSystemService (NotificationService);

			if (!String.IsNullOrEmpty (registrationId)) {
				NativeRegistration = await Hub.RegisterNativeAsync (registrationId, new[] {"Native"});

				var notificationNativeRegistration = new Notification (Resource.Drawable.Icon, "Native Registered");
				var pendingIntentNativeRegistration = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);
				notificationNativeRegistration.SetLatestEventInfo (this, "Native Reg.-ID", NativeRegistration.RegistrationId, pendingIntentNativeRegistration);
				nMgr.Notify (_messageId, notificationNativeRegistration);
				_messageId++;
			}
			else if (!String.IsNullOrEmpty (error)) {
				var notification = new Notification (Resource.Drawable.Icon, "Gcm Registration Failed.");
				var pendingIntent = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);
				notification.SetLatestEventInfo (this, "Gcm Registration Failed", error, pendingIntent);
				nMgr.Notify (_messageId, notification);
				_messageId++;
			}
			else if (!String.IsNullOrEmpty (unregistration)) {
				if (NativeRegistration != null)
					await Hub.UnregisterAsync (NativeRegistration);

				var notification = new Notification (Resource.Drawable.Icon, "Unregistered successfully.");
				var pendingIntent = PendingIntent.GetActivity (this, 0, new Intent (this, typeof(MainActivity)), 0);
				notification.SetLatestEventInfo (this, "MyIntentService", "Unregistered successfully.", pendingIntent);
				nMgr.Notify (_messageId, notification);
				_messageId++;
			}
		}
开发者ID:codebase2015,项目名称:Xamarin.NotificationHub,代码行数:35,代码来源:RemoteNotificationService.cs

示例2: OnActivityResult

		protected override void OnActivityResult (int requestCode, Result resultCode, Intent data)
		{

			base.OnActivityResult (requestCode, resultCode, data);

			switch (resultCode) {
			case Result.Ok:

				AppCommon.Inst.FbAccessToken = data.GetStringExtra ("AccessToken");
				string error = data.GetStringExtra ("Exception");

				// TODO Localization for facebook errors
				if (!string.IsNullOrEmpty(error))
					Utils.Alert (this, "Failed to Log In", "Reason: " + error, false);
				else {
					try
					{
						AppCommon.Inst.InitUser (data.GetStringExtra ("UserId"));
						this.StartNextActivity<ReqBookingSrcActivity> ();
					}
					catch(TException ex) 
					{
						Utils.HandleTException (this, ex);
					}
				}
				break;
			case Result.Canceled:
				Utils.Alert (this, "Failed to Log In", "User Cancelled", false);
				break;
			default:
				break;
			}
		}
开发者ID:CJDevWorks,项目名称:SavariWala,代码行数:33,代码来源:LoginActivity.cs

示例3: OnReceive

		public override void OnReceive (Context context, Intent intent)
		{
			var message = intent.GetStringExtra("message");
			var title = intent.GetStringExtra("title");

			var notIntent = new Intent(context, typeof(MainScreen));
			var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent);
			var manager = NotificationManagerCompat.From(context);

			var style = new NotificationCompat.BigTextStyle();
			style.BigText(message);

			int resourceId = Resource.Drawable.HappyBaby;

			var wearableExtender = new NotificationCompat.WearableExtender()
				.SetBackground(BitmapFactory.DecodeResource(context.Resources, resourceId));

			//Generate a notification with just short text and small icon
			var builder = new NotificationCompat.Builder(context)
				.SetContentIntent(contentIntent)
				.SetSmallIcon(Resource.Drawable.HappyBaby)
				.SetSound(Android.Net.Uri.Parse("android.resource://com.iinotification.app/"+ Resource.Raw.babySound))
				.SetContentTitle("Hey Mom")
				.SetContentText("Here I'm :)")
				.SetStyle(style)
				.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
				.SetAutoCancel(true)
				.Extend(wearableExtender);

			var notification = builder.Build();
			manager.Notify(0, notification);
		}
开发者ID:XnainA,项目名称:CustomLocalNotification,代码行数:32,代码来源:OneShotAlarm.cs

示例4: OnReceive

		public override void OnReceive (Context context, Intent intent) {
			if (RetreiveLatestReceiver.IsAvailableVersion(context)) {
				intent.PutExtra ("title", string.Format(context.Resources.GetString(Resource.String.notification_title), "WhatsApp " + RetreiveLatestReceiver.GetLatestVersion ()));
				intent.PutExtra ("message", string.Format(context.Resources.GetString(Resource.String.notification_description), context.Resources.GetString(Resource.String.app_name)));
				var message = intent.GetStringExtra ("message");
				var title = intent.GetStringExtra ("title");

				var notIntent = new Intent (context, typeof(MainActivity));
				var contentIntent = PendingIntent.GetActivity (context, 0, notIntent, PendingIntentFlags.CancelCurrent);
				var manager = NotificationManagerCompat.From (context);

				var style = new NotificationCompat.BigTextStyle ().BigText (message);
				int resourceId = Resource.Drawable.ic_launcher;

				var wearableExtender = new NotificationCompat.WearableExtender ().SetBackground (BitmapFactory.DecodeResource (context.Resources, resourceId));

				// Generate notification (short text and small icon)
				var builder = new NotificationCompat.Builder (context);
				builder.SetContentIntent (contentIntent);
				builder.SetSmallIcon (Resource.Drawable.ic_launcher);
				builder.SetContentTitle (title);
				builder.SetContentText (message);
				builder.SetStyle (style);
				builder.SetWhen (Java.Lang.JavaSystem.CurrentTimeMillis ()); // When the AlarmManager will check changes?
				builder.SetAutoCancel (true);
				builder.Extend (wearableExtender); // Support Android Wear, yeah!

				var notification = builder.Build ();
				manager.Notify (0, notification);
			}
		}
开发者ID:javiersantos,项目名称:WhatsAppBetaUpdater.Xamarin,代码行数:31,代码来源:AlarmReceiver.cs

示例5: OnReceive

 public override void OnReceive(Context context, Intent intent)
 {
     var str1 = intent.GetStringExtra ("team1");
     var str2 = intent.GetStringExtra ("team2");
     var count1 = intent.GetStringExtra ("count");
     var iconId = intent.GetStringExtra ("icon");
     Console.WriteLine ("Servise Start");
     PowerManager pm = (PowerManager)context.GetSystemService(Context.PowerService);
     PowerManager.WakeLock w1 = pm.NewWakeLock (WakeLockFlags.Partial, "NotificationReceiver");
     w1.Acquire ();
     Notification.Builder builder = new Notification.Builder (context)
         .SetContentTitle (context.Resources.GetString(Resource.String.matchIsStarting))
         .SetContentText (str1+" VS. "+str2)
         .SetSmallIcon (Convert.ToInt32(iconId));
     // Build the notification:
     Notification notification = builder.Build();
     notification.Defaults = NotificationDefaults.All;
     // Get the notification manager:
     NotificationManager notificationManager = (NotificationManager)context.GetSystemService (Context.NotificationService);
     // Publish the notification:
     int notificationId = Convert.ToInt32(count1);
     notificationManager.Notify (notificationId, notification);
     w1.Release ();
     var tempd = DateTime.UtcNow;
     Console.WriteLine ("Alarm: " + tempd);
 }
开发者ID:mexaniksay,项目名称:GamePro02,代码行数:26,代码来源:AlarmM.cs

示例6: ReadNotification

        public static AppNotification ReadNotification(Intent intent)
        {
            var t = intent.GetStringExtra ("Type");
            if (t == null)
                t = intent.GetStringExtra ("event");
            if (t == null)
                return new UnknownNotification ();

            Type type;
            if (!notificationTypes.TryGetValue (t, out type))
                return new UnknownNotification ();

            var not = (AppNotification)Activator.CreateInstance (type);

            foreach (var p in not.GetType ().GetProperties (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)) {
                var arg = (IntentArg) Attribute.GetCustomAttribute (p, typeof(IntentArg));
                if (arg != null) {
                    object val = GetValue (intent, arg.Name ?? p.Name, p.PropertyType);
                    p.SetValue (not, val, null);
                }
            }

            foreach (var p in not.GetType ().GetFields (System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)) {
                var arg = (IntentArg) Attribute.GetCustomAttribute (p, typeof(IntentArg));
                if (arg != null) {
                    object val = GetValue (intent, arg.Name ?? p.Name, p.FieldType);
                    p.SetValue (not, val);
                }
            }
            return not;
        }
开发者ID:slluis,项目名称:TrackMe,代码行数:31,代码来源:Notification.cs

示例7: CreateNotification

        // Creates a new notification depending on makeHeadsUpNotification.
        public Notification CreateNotification(Context context, Intent intent)
        {
            // indicate that this sms comes from server
            intent.PutExtra ("source", "server");

            // Parse bundle extras
            string contactId = intent.GetStringExtra("normalizedPhone");
            string message = intent.GetStringExtra("message");

            // Getting contact infos
            var contact = Contact.GetContactByPhone (contactId, context);

            var builder = new Notification.Builder (context)
                .SetSmallIcon (Resource.Drawable.icon)
                .SetPriority ((int)NotificationPriority.Default)
                .SetCategory (Notification.CategoryMessage)
                .SetContentTitle (contact.DisplayName != "" ? contact.DisplayName : contactId)
                .SetContentText (message)
                .SetSound (RingtoneManager.GetDefaultUri (RingtoneType.Notification));

            var fullScreenPendingIntent = PendingIntent.GetActivity (context, 0,
                intent, PendingIntentFlags.CancelCurrent);
                builder.SetContentText (message)
                       .SetFullScreenIntent (fullScreenPendingIntent, true)
                       .SetContentIntent (fullScreenPendingIntent);

            return builder.Build ();
        }
开发者ID:mrancourt,项目名称:voip-messenger,代码行数:29,代码来源:HeadsUpNotificationFragment.cs

示例8: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            if (intent != null)
            {
                String data = intent.GetStringExtra(BARCODE_VALUE);
                String typeString = intent.GetStringExtra(BARCODE_TYPE);
                Symbology symbology = Symbology.UNKNOWN;
                switch (typeString.ToUpper())
                {
                    case "UPCE":
                        symbology = Symbology.UPCE;
                        break;
                    case "EAN13":
                        symbology = Symbology.EAN13;
                        break;
                    case "EAN8":
                        symbology = Symbology.EAN8;
                        break;
                    default:
                        symbology = Symbology.UNKNOWN;
                        break;
                }

                RedLaser.Instance.TriggerScan(data, symbology);
                Log.Info("MonoCross", "response received from scan " + data + " : " + typeString);
            }
            else
            {
                Log.Warn("MonoCross", "weird response received");
            }
        }
开发者ID:oduma,项目名称:Sciendo.Fitas.Droid,代码行数:31,代码来源:RedLaser.MD.cs

示例9: OnReceive

		private const long WIDGET_REFRESH_DELAY_MS = 5000; //5 Seconds


			public override void OnReceive(Context context, Intent intent) {

			// Refresh the widget after a push comes in
			if (PushManager.ActionPushReceived == intent.Action) {
				RichPushWidgetUtils.RefreshWidget(context, WIDGET_REFRESH_DELAY_MS);
			}

			// Only takes action when a notification is opened
			if (PushManager.ActionNotificationOpened != intent.Action) {
				return;
			}

			// Ignore any non rich push notifications
			if (!RichPushManager.IsRichPushMessage(intent.Extras)) {
				return;
			}

			string messageId = intent.GetStringExtra(EXTRA_MESSAGE_ID_KEY);
			Logger.Debug("Notified of a notification opened with id " + messageId);

			Intent messageIntent = null;

			// Set the activity to receive the intent
			if ("home" == intent.GetStringExtra(ACTIVITY_NAME_KEY)) {
				messageIntent = new Intent(context, typeof (MainActivity));
			} else {
				// default to the Inbox
				messageIntent =  new Intent(context, typeof (InboxActivity));
			}

			messageIntent.PutExtra(RichPushApplication.MESSAGE_ID_RECEIVED_KEY, messageId);
			messageIntent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop | ActivityFlags.NewTask);
			context.StartActivity(messageIntent);
		}
开发者ID:BratislavDimitrov,项目名称:monodroid-samples,代码行数:37,代码来源:PushReceiver.cs

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

示例11: OnHandleIntent

        protected override void OnHandleIntent(Intent intent)
        {
            try {
                Context context = this.ApplicationContext;
                string action = intent.Action;

                if (action.Equals ("com.google.android.c2dm.intent.REGISTRATION")) {
                    MainActivity.appRegID = intent.GetStringExtra ("registration_id");
                    Console.WriteLine(intent.GetStringExtra ("registration_id"));
                } else if (action.Equals ("com.google.android.c2dm.intent.RECEIVE")) {

            //					PendingIntent resultPendingIntent = PendingIntent.GetActivity(context,0,new Intent(context,typeof(MainActivity)),0);
            //					// Build the notification
            //					NotificationCompat.Builder builder = new NotificationCompat.Builder(context)
            //						.SetAutoCancel(true)
            //							.SetContentIntent(resultPendingIntent)
            //							.SetContentTitle("新通知來了")
            //							.SetSmallIcon(Resource.Drawable.xsicon)
            //							.SetContentText(intent.GetStringExtra("alert"));
            //
            //					NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService);
            //					notificationManager.Notify(0, builder.Build());
                    createNotification("您有新的信息",intent.GetStringExtra("alert"));
                }
            } finally {
                lock (LOCK) {
                    //Sanity check for null as this is a public method
                    if (sWakeLock != null)
                        sWakeLock.Release ();
                }
            }
        }
开发者ID:Terry-Lin,项目名称:MDCC,代码行数:32,代码来源:PushService.cs

示例12: OnReceive

			/// <param name="context">The Context in which the receiver is running.</param>
			/// <param name="intent">The Intent being received.</param>
			/// <summary>
			/// This method is called when the BroadcastReceiver is receiving an Intent
			///  broadcast.
			/// </summary>
			public override void OnReceive (Context context, Intent intent)
			{
				//get action from intent
				string action = intent.Action;
				//get command from action
				string cmd = intent.GetStringExtra("command");
				//write info
				Console.WriteLine("mIntentReceiver.onReceive " + action + " / " + cmd);
				//get artist from intent
				String artist = intent.GetStringExtra("artist");
				//get album from intent
				String album = intent.GetStringExtra("album");
				//get track from intent
				String track = intent.GetStringExtra("track");
				//write all info
				Console.WriteLine(artist+":"+album+":"+track);

				//set content title to notification builder
				builder.SetContentTitle (artist);
				//set contennt text to notification builder
				builder.SetContentText (track+"-"+album);
				//set big style to builder
				builder.SetStyle (new NotificationCompat.BigTextStyle ().BigText (track + "-" + album));
				try
				{
					//seach album thumbnail from itunes api
					var json = new System.Net.WebClient().DownloadString("http://itunes.apple.com/search?term=" + Uri.EscapeDataString(track+" "+album+" "+artist) + "&country=mx&limit=1&entity=song");
					//parse json downloaded to json object
					Newtonsoft.Json.Linq.JObject o = Newtonsoft.Json.Linq.JObject.Parse(json);
					//get json results child
					var n = o["results"];
					//get firts "artworkUrl100" property
					string val = (string)n[0]["artworkUrl100"];
					//check if exist thumbnail
					if (string.IsNullOrEmpty(val))
					{
						//if thumbnail doesnt exists set default image to largeicon
						builder.SetLargeIcon(BitmapFactory.DecodeResource(null,Resource.Drawable.ic_launcher));
					}
					else
					{
						//change 100x100 size of thumbnail to 600x600 image
						StringBuilder builde = new StringBuilder(val);
						builde.Replace("100x100", "600x600");
						//webclient to download image
						WebClient c = new WebClient();
						//downloadimage to bytearray
						byte[] data = c.DownloadData(builde.ToString());
						//convert byte[] downloaded to bitmap and set large icon to builder
						builder.SetLargeIcon(Bitmap.CreateScaledBitmap(BitmapFactory.DecodeByteArray(data,0,data.Length),150,150,false));
					}
				}
				catch(Exception e)
				{
					//set default image to largeicon
					builder.SetLargeIcon(BitmapFactory.DecodeResource(null,Resource.Drawable.ic_launcher));
				}
				//update/create a notification
				notificationManager.Notify(0, builder.Build());
			}
开发者ID:EnriqueProinfo,项目名称:Mono,代码行数:66,代码来源:MainActivity.cs

示例13: OnReceive

        public override void OnReceive(Context context, Intent intent)
        {
            var id = intent.GetStringExtra("id");
            var message = intent.GetStringExtra("message");
            var title = intent.GetStringExtra("title");

            var notIntent = new Intent(context, typeof(MainActivity));
            notIntent.PutExtra("id", id);
            var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent);
            var manager = NotificationManagerCompat.From(context);

            int resourceId = Resource.Drawable.ic_launcher_xx;

            var wearableExtender = new NotificationCompat.WearableExtender()
                .SetBackground(BitmapFactory.DecodeResource(context.Resources, resourceId));

            //Generate a notification with just short text and small icon
            var builder = new NotificationCompat.Builder(context)
                            .SetContentIntent(contentIntent)
                            .SetSmallIcon(Resource.Drawable.ic_launcher_xx)
                            .SetContentTitle(title)
                            .SetContentText(message)
                            .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis())
                            .SetAutoCancel(true)
                            .Extend(wearableExtender);

            var notification = builder.Build();
            manager.Notify(int.Parse(id), notification);
        }
开发者ID:threezool,项目名称:LaunchPal,代码行数:29,代码来源:AlarmReceiver.cs

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

示例15: OnActivityResult

        /// <inheritdoc/>
        public override void OnActivityResult(int requestCode, int resultCode, Intent data)
        {
            ZTnTrace.Trace(MethodBase.GetCurrentMethod());

            switch (requestCode)
            {
                case AddNewAccount:
                    switch (resultCode)
                    {
                        case -1:
                            var battleTag = data.GetStringExtra("battleTag");
                            var host = data.GetStringExtra("host");

                            D3Context.Instance.DbAccounts.Insert(battleTag, host);

                            IListAdapter careerAdapter = new SimpleCursorAdapter(Activity, Android.Resource.Layout.SimpleListItem2, cursor, accountsFromColumns, accountsToId);
                            Activity.FindViewById<ListView>(Resource.Id.AccountsListView)
                                .Adapter = careerAdapter;

                            Toast.MakeText(Activity, "Account added", ToastLength.Short)
                                .Show();
                            break;
                    }
                    break;
            }

            base.OnActivityResult(requestCode, resultCode, data);
        }
开发者ID:djtms,项目名称:D3-Android-by-ZTn,代码行数:29,代码来源:CareersListFragment.cs


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