public void ShowNotification(Intent intent) { var id = intent.GetIntExtra("id", 0); var title = intent.GetStringExtra("title"); var body = intent.GetStringExtra("message"); var main_intent = new Intent(this, typeof(MainActivity)); main_intent.PutExtra("type", "alarm"); main_intent.PutExtra("id", id); var builder = new Notification.Builder(this); //builder.SetGroup("keep.grass"); builder.SetTicker(title); builder.SetContentTitle(title); builder.SetContentText(body); builder.SetContentIntent ( PendingIntent.GetActivity ( this, id, main_intent, PendingIntentFlags.UpdateCurrent ) ); builder.SetSmallIcon(Resource.Drawable.icon); builder.SetLargeIcon(BitmapFactory.DecodeResource(this.Resources, Resource.Drawable.icon)); builder.SetDefaults(NotificationDefaults.All); builder.SetAutoCancel(true); ((NotificationManager)this.GetSystemService(NotificationService)) .Notify(id, builder.Build()); }
public static void ShowNotification(Context context, NotificacaoDto notificacao) { var builder = new Notification.Builder(context) .SetContentTitle(notificacao.Titulo) .SetContentText(notificacao.Descricao) .SetSmallIcon(Resource.Drawable.ic_empresa); NotificationDefaults?notificationalerts = null; if (notificacao.NotificarComSom) { notificationalerts = NotificationDefaults.Sound; } if (notificacao.NotificarComLuz) { notificationalerts = notificationalerts | NotificationDefaults.Lights; } if (notificacao.NotificarComVibracao) { notificationalerts = notificationalerts | NotificationDefaults.Vibrate; } if (notificationalerts != null) { builder.SetDefaults(notificationalerts.Value); } var notificationManager = NotificationManager.FromContext(context); notificationManager.Notify(Convert.ToInt32(DateTime.Now.ToString("hhmmssms")), builder.Build()); }
private void HandleEnterZone(Zone z) { Log.Debug(TAG, "Enter zone " + z.Name); Intent notificationIntent = new Intent(this, typeof(NotificationActivity)); notificationIntent.PutExtra("zone_id", z.Id); notificationIntent.PutExtra("zone_name", z.Name); notificationIntent.PutExtra("zone_color", z.Color); notificationIntent.PutExtra("zone_alias", z.Alias); PendingIntent pendingIntent = PendingIntent.GetActivity( this, z.Id, notificationIntent, PendingIntentFlags.UpdateCurrent); Notification.Builder notificationBuilder = new Notification.Builder(this); notificationBuilder.SetSmallIcon(Resource.Drawable.elm_logo); notificationBuilder.SetContentTitle("New zone"); notificationBuilder.SetContentText("You have entered zone '" + z.Name + "'"); notificationBuilder.SetDefaults(NotificationDefaults.Sound); notificationBuilder.SetAutoCancel(true); notificationBuilder.SetContentIntent(pendingIntent); // Get an instance of the NotificationManager service NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); //Build the notification and issues it with notification manager. notificationManager.Notify(z.Id, notificationBuilder.Build()); }
public override void OnReceive(Context context, Intent intent) { // var notificationManager = (NotificationManager)context.GetSystemService(Context.NotificationService); // var resultIntent = new Intent(context, typeof(AfazerService)); /*TaskStackBuilder stackBuilder = TaskStackBuilder.Create(context); * stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(AfazerService))); * stackBuilder.AddNextIntent(resultIntent);*/ // //PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent); // var builder = new Notification.Builder(context); builder.SetAutoCancel(true); //builder.SetContentIntent(resultPendingIntent); builder.SetContentTitle(_title); builder.SetContentText(_description); builder.SetDefaults(NotificationDefaults.All); builder.SetSmallIcon(Resource.Drawable.icon); // notificationManager.Notify(100, builder.Build()); }
private void Button_Click(object sender, EventArgs e) { notyBuilder = new Notification.Builder(this); notyBuilder.SetContentTitle("عنوان پیام"); notyBuilder.SetContentText("متن پیام در اینجا قرار میگیرد"); notyBuilder.SetSmallIcon(Resource.Drawable.noty_small_icon); notyBuilder.SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.noty_large_icon)); notyBuilder.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()); notyBuilder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); notyBuilder.SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Notification)); notyBuilder.SetAutoCancel(true); notyBuilder.SetPriority((int)NotificationPriority.High); if ((int)Android.OS.Build.VERSION.SdkInt >= 21) { notyBuilder.SetVisibility(NotificationVisibility.Public); notyBuilder.SetCategory(Notification.CategoryEmail); } #region BigTextStyle Notification.BigTextStyle textStyle = new Notification.BigTextStyle(); string longTextMessage = "I went up one pair of stairs."; longTextMessage += " / Just like me. "; textStyle.BigText(longTextMessage); textStyle.SetSummaryText("The summary text goes here."); //notyBuilder.SetStyle(textStyle); #endregion #region InboxStyle var inboxStyle = new Notification.InboxStyle(); inboxStyle.AddLine("Cheeta: Bananas on sale"); inboxStyle.AddLine("George: Curious about your blog post"); inboxStyle.AddLine("Nikko: Need a ride to Evolve?"); inboxStyle.SetSummaryText("+2 more"); notyBuilder.SetStyle(inboxStyle); #endregion #region imageStyle var imageStyle = new Notification.BigPictureStyle(); imageStyle.BigPicture(BitmapFactory.DecodeResource(Resources, Resource.Drawable.facebook)); imageStyle.SetSummaryText("+2 more"); //notyBuilder.SetStyle(imageStyle); #endregion var notification = notyBuilder.Build(); var notyManager = GetSystemService(Context.NotificationService) as NotificationManager; notyManager.Notify(notyId, notification); }
public void ShowNotification(string title, string messageTitle, string messege, bool handleClickNeeded ) { try { // Set up an intent so that tapping the notifications returns to this app: Intent intent = new Intent ( Application.Context , typeof( NotificationClick )); //intent.RemoveExtra ("MyData"); intent.PutExtra ("Message", messege); intent.PutExtra ("Title", title); string chatMsg = messege; string chatTouserID = ""; if( title == "chat" ) { string[] delimiters = { "&&" }; string[] clasIDArray = messege.Split(delimiters, StringSplitOptions.None); chatMsg = clasIDArray [0]; chatTouserID = clasIDArray [1]; } // Create a PendingIntent; we're only using one PendingIntent (ID = 0): const int pendingIntentId = 0; PendingIntent pendingIntent = PendingIntent.GetActivity ( MainActivity.GetMainActivity() , pendingIntentId, intent, PendingIntentFlags.OneShot); // Instantiate the builder and set notification elements: Notification.Builder builder = new Notification.Builder(MainActivity.GetMainActivity()) .SetContentTitle(title) .SetContentText(chatMsg) .SetDefaults(NotificationDefaults.Sound) .SetAutoCancel( true ) .SetSmallIcon(Resource.Drawable.app_icon); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); if( handleClickNeeded ) builder.SetContentIntent( pendingIntent ); // Build the notification: Notification notification = builder.Build(); // Get the notification manager: NotificationManager notificationManager = (NotificationManager)MainActivity.GetMainActivity().GetSystemService(Context.NotificationService); // Publish the notification: const int notificationId = 0; notificationManager.Notify(notificationId, notification); } catch (Exception ex) { string err = ex.Message; } }
//used to generate local notifications public void CreateNotification(dynamic response) { TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this); Intent wklIntent = new Intent(this, typeof(WorkListActivity)); stackBuilder.AddNextIntent(wklIntent); PendingIntent pendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.OneShot); //id=0 Notification.Style style; if (response.Count == 1) { Notification.BigTextStyle textStyle = new Notification.BigTextStyle(); textStyle.BigText(response[0]["MSG_CONTENT"]); textStyle.SetSummaryText(response[0]["MSG_TITLE"]); style = textStyle; } else { Notification.InboxStyle inboxStyle = new Notification.InboxStyle(); inboxStyle.AddLine(response[0]["MSG_CONTENT"]); inboxStyle.AddLine(response[1]["MSG_CONTENT"]); if (response.Count > 2) { inboxStyle.SetSummaryText("+" + (response.Count - 2) + " more"); } style = inboxStyle; } Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("PeoplePlus Notification") .SetContentText("Pending Tasks in your WorkList Viewer") .SetSmallIcon(Resource.Drawable.login3) .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.login3)) .SetAutoCancel(true) .SetContentIntent(pendingIntent); if ((int)Build.VERSION.SdkInt >= 21) { builder.SetVisibility(NotificationVisibility.Private) .SetCategory(Notification.CategoryAlarm) .SetCategory(Notification.CategoryCall) .SetStyle(style); } builder.SetPriority((int)NotificationPriority.High); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); NotificationManager notificationManager = GetSystemService(NotificationService) as NotificationManager; notificationManager.Notify(0, notification); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { int TimerWait = 60000; Timer _timer; int notificationCount = 0; List <FeedingTime> usedFeedingtimes = new List <FeedingTime>(); Thread t = new Thread(() => { _timer = new Timer(o => { FeedingTime timeToCheck; DateTime now = DateTime.Now; foreach (Animal a in AttractionDataBase.animalsToWatch) { if (a.HasFeedingTime && a.IsInSeason) { timeToCheck = a.NextFeeding; Console.WriteLine(a.Name + " - " + a.NextFeeding + " : " + timeToCheck.TimeOfDay.AddMinutes(-5)); if (now.Hour == timeToCheck.TimeOfDay.AddMinutes(-5).Hour&& now.Minute == timeToCheck.TimeOfDay.AddMinutes(-5).Minute) { System.IO.Stream ims = Assets.Open("img/AnimalHeaders/" + a.Name + "Header.png"); // load image as Drawable Bitmap bitmap = BitmapFactory.DecodeStream(ims); ims.Close(); Notification.Builder builder = new Notification.Builder(this) .SetContentTitle("Fodring hos " + a.Name) .SetContentText("om " + lookAheadTime + " minutter.") .SetSmallIcon(Resource.Drawable.logo); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; notificationManager.Notify(notificationCount++, notification); } } } Console.WriteLine(DateTime.Now.Minute); }, null, 0, TimerWait); }); if (t.IsAlive == false) { t.Start(); } return(StartCommandResult.NotSticky); }
public Notification.Builder CreateNotificationBuilder() { var notification = new Notification.Builder(this) .SetAutoCancel(true) .SetContentTitle("BaBook chat") .SetSmallIcon(Resource.Drawable.ic_chat_bubble_white_24dp); if (!MuteNotification) { notification?.SetDefaults(NotificationDefaults.Vibrate); } return(notification); }
void NotifyTest() { Intent intent = new Intent(Application.Context, typeof(SecondActivity)); PendingIntent pIntent = PendingIntent.GetActivity(Application.Context, 0, intent, PendingIntentFlags.UpdateCurrent); Notification.Builder builder = new Notification.Builder(Application.Context); builder.SetContentText("内容").SetContentTitle("标题").SetAutoCancel(true).SetLights(Color.Green, 1000, 1000); builder.SetDefaults(NotificationDefaults.All).SetPriority((int)IntentFilterPriority.HighPriority); builder.SetContentIntent(pIntent).SetSmallIcon(Resource.Drawable.notification_template_icon_bg); Notification notification = builder.Build(); NotificationManager nm = (NotificationManager)GetSystemService(NotificationService); nm.Notify(1, notification); }
private async void Current_ConnectivityChanged(object sender, Plugin.Connectivity.Abstractions.ConnectivityChangedEventArgs e) { // Get the notification manager: NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; Notification.Builder builder1 = new Notification.Builder(this); Notification notification1 = builder1.Build(); if (e.IsConnected) { var eValue = App.DAUtil.GetAll <OfflineItem>("OfflineItem"); if (eValue.Count > 0) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.OneShot); builder1.SetContentTitle("Nokcoot"); builder1.SetContentText("Offline drafts uploaded"); builder1.SetAutoCancel(true); builder1.SetDefaults(NotificationDefaults.Sound); builder1.SetSmallIcon(Resource.Drawable.logo); builder1.SetContentIntent(pendingIntent); builder1.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()); notification1 = builder1.Build(); notification1.Defaults |= NotificationDefaults.Vibrate; await OAuthHelper.SyncOfflineItems(); } MessagingCenter.Subscribe <object, string>(this, "notify", (s, e1) => { Device.BeginInvokeOnMainThread(() => { if (App.DAUtil.GetAll <OfflineItem>("OfflineItem").Count == 0) { notificationManager.Notify(SERVICE_RUNNING_NOTIFICATION_ID1, notification1); StopForeground(true); } }); }); // notification.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); button1 = FindViewById <Button>(Resource.Id.button1); Notification.Builder builder = new Notification.Builder(this); const int notificationID = 0; NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; bool firstNotificationSent = false; button1.Click += delegate { if (!firstNotificationSent) { // Notifications at a minimum have: icon, title, message & time builder.SetContentText("My app notification"); builder.SetContentText("Hi there this is a notification(obiviously)"); builder.SetSmallIcon(Resource.Mipmap.ic_home_black_24dp); // see android documentation for icon sizes // this is deprecated !!!!!! builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Lights); Notification notification = builder.Build(); // service that displays the notification notificationManager.Notify(notificationID, notification); firstNotificationSent = true; } else { builder.SetContentTitle("Update to notification"); builder.SetContentText("Stop pressing the button!"); Notification notif = builder.Build(); notificationManager.Notify(notificationID, notif); } }; }
public override StartCommandResult OnStartCommand(Intent intent, [GeneratedEnum] StartCommandFlags flags, int startId) { new Task(() => { PendingIntent pIntent = PendingIntent.GetActivity(this, 0, intent, 0); Notification.Builder builder = new Notification.Builder(this); builder.SetContentTitle("hello"); builder.SetContentText("hello"); builder.SetSmallIcon(Resource.Drawable.Icon); builder.SetPriority(1); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); builder.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()); Notification notifikace = builder.Build(); NotificationManager notificationManager = GetSystemService(Context.NotificationService) as NotificationManager; const int notificationId = 0; notificationManager.Notify(notificationId, notifikace); }).Start(); return(StartCommandResult.Sticky); }
public void SendNotificatios(string body, string Header) { Notification.Builder builder = new Notification.Builder(this); builder.SetSmallIcon(Resource.Drawable.Icon); var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.ClearTop); PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, intent, 0); builder.SetContentIntent(pendingIntent); builder.SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.Icon)); builder.SetContentTitle(Header); builder.SetContentText(body); builder.SetDefaults(NotificationDefaults.Sound); builder.SetAutoCancel(true); NotificationManager notificationManager = (NotificationManager)GetSystemService(NotificationService); notificationManager.Notify(1, builder.Build()); }
private void BtnNotify_Click(object sender, EventArgs e) { //Intent intent = new Intent(this, typeof(MainActivity)); //const int pendingIntentId = 0; //PendingIntent pendingIntent = // PendingIntent.GetActivity(this, pendingIntentId, intent, PendingIntentFlags.OneShot); Notification.Builder builder = new Notification.Builder(this); //builder.SetContentIntent(pendingIntent); builder.SetPriority((int)NotificationPriority.High); builder.SetContentTitle("알려드립니다!!"); builder.SetContentText("Hello World! This is my first notification!"); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate | NotificationDefaults.Lights); builder.SetSmallIcon(Resource.Drawable.Icon); Notification noti = builder.Build(); // Build the notification: Notification notification = builder.Build(); NotificationManager manager = GetSystemService(Context.NotificationService) as NotificationManager; manager.Notify(101, noti); }
private void ShowFinishedNotification(NotificationManager notificationManager) { var resultIntent = new Intent(MainActivity.Instance, typeof(MainActivity)); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); var builder = new Notification.Builder(this) .SetContentTitle("Your meal is ready!") .SetSmallIcon(Resource.Drawable.Icon_24) .SetContentIntent(PendingIntent.GetActivity(MainActivity.Instance, 0, resultIntent, PendingIntentFlags.OneShot)) .SetAutoCancel(true) .SetPriority((int)NotificationPriority.High); if (!MainActivity.Instance.IsVisible) { builder .SetDefaults(NotificationDefaults.All) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Alarm)); } notificationManager.Notify(MealReadyNotificationId, builder.Build()); }
private void ShowActionNotification(Milestone milestone, NotificationManager notificationManager, int i) { var resultIntent = new Intent(MainActivity.Instance, typeof(MainActivity)); resultIntent.SetFlags(ActivityFlags.NewTask | ActivityFlags.ClearTask); var builder = new Notification.Builder(this) .SetContentTitle($"Put the {milestone.ItemsToStartCooking} in at {milestone.Temperature}°") .SetSmallIcon(Resource.Drawable.Icon_24) .SetContentIntent(PendingIntent.GetActivity(MainActivity.Instance, 0, resultIntent, PendingIntentFlags.OneShot)) .SetAutoCancel(true) .SetPriority((int)NotificationPriority.High); if (!MainActivity.Instance.IsVisible) { builder .SetDefaults(NotificationDefaults.All) .SetSound(RingtoneManager.GetDefaultUri(RingtoneType.Alarm)); } notificationManager.Notify(i, builder.Build()); }
//used to generate local notifications for remote messages void SendNotification(Dictionary <string, string> response) { TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this); Intent wklIntent = new Intent(this, typeof(WorkListActivity)); stackBuilder.AddNextIntent(wklIntent); PendingIntent pendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.OneShot); //id=0 Notification.BigTextStyle style = new Notification.BigTextStyle(); style.BigText(response["MSG_CONTENT"]); style.SetSummaryText(response["MSG_TITLE"]); Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("PeoplePlus Notification") .SetContentText("Pending Task(s) in your WorkList Viewer") .SetSmallIcon(Resource.Drawable.neptunelogo) .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Drawable.neptunelogo)) .SetAutoCancel(true) .SetContentIntent(pendingIntent); if ((int)Build.VERSION.SdkInt >= 21) { builder.SetVisibility(NotificationVisibility.Private) .SetCategory(Notification.CategoryAlarm) .SetCategory(Notification.CategoryCall) .SetStyle(style); } builder.SetPriority((int)NotificationPriority.High); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); NotificationManager notificationManager = GetSystemService(NotificationService) as NotificationManager; notificationManager.Notify(0, notification); }
protected override void OnHandleIntent(Intent intent) { if (running) { return; } running = true; meetingReceiver = new MeetingReceiver(); IntentFilter intentFilter = new IntentFilter(ActionNewMeeting); RegisterReceiver(meetingReceiver, intentFilter); Task <Core.Common.Result <IList <Meeting> > > task = eventService.FetchLatestEvent(); while (running) { if (task.IsCompleted || task.IsCanceled || task.IsFaulted) { if (task.IsCompleted) { if (!task.Result.HasError) { var newMeetings = task.Result.Model .Where((meeting) => { return(meeting.MeetingCreatedAt > ServiceContext.Instance.LatestMeetingTime); }) .ToList(); if (newMeetings.Count != 0) { newMeetings.Sort((x, y) => { if (x.MeetingCreatedAt > y.MeetingCreatedAt) { return(-1); } else if (x.MeetingCreatedAt == y.MeetingCreatedAt) { return(0); } else { return(1); } }); ServiceContext.Instance.LatestMeetingTime = newMeetings[0].MeetingCreatedAt; StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < newMeetings.Count; i++) { strBuilder.Append(newMeetings[i].MeetingName); if (i != newMeetings.Count - 1) { strBuilder.Append("\n"); } } Notification.Builder builder = new Notification.Builder(this); builder.SetSmallIcon(Resource.Drawable.icon); builder.SetTicker($"{newMeetings.Count}条新会议\n"); builder.SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()); builder.SetContentTitle("新的会议"); builder.SetContentText(strBuilder.ToString()); Intent intent1 = new Intent(ActionNewMeeting); PendingIntent pendingIntent = PendingIntent.GetBroadcast(this, 0, intent1, PendingIntentFlags.CancelCurrent); builder.SetContentIntent(pendingIntent);//设置点击过后跳转的activity /*builder.setDefaults(Notification.DEFAULT_SOUND);//设置声音 * builder.setDefaults(Notification.DEFAULT_LIGHTS);//设置指示灯 * builder.setDefaults(Notification.DEFAULT_VIBRATE);//设置震动*/ builder.SetDefaults(NotificationDefaults.All); //设置全部 Notification notification = builder.Build(); //4.1以上用.build(); notification.Flags |= NotificationFlags.AutoCancel; // 点击通知的时候cancel掉 NotificationManager manager = (NotificationManager)GetSystemService(NotificationService); manager.Notify(1, notification); MessagingCenter.Send(Xamarin.Forms.Application.Current, "NewMeeting"); } } try { Thread.Sleep(3000); } catch (InterruptedException) {} } task = eventService.FetchLatestEvent(); } } }
//TODO: Remove Console.WriteLine() public static void ReceiveEvent(Event events) { DateTime now = DateTime.Now.ToLocalTime(); string currentTime = (string.Format("{0}", now)); if (events.EventType == EventType.IgnitionOff) { Console.WriteLine("Ignition Off!"); } else if (events.EventType == EventType.IgnitionOn) { Console.WriteLine("Ignition On!"); if (!(savedPref.GetInt("startHour", 25) == 25)) { TimeSpan startTime = new TimeSpan(savedPref.GetInt("startHour", 0), savedPref.GetInt("startMinute", 0), 0); TimeSpan endTime = new TimeSpan(savedPref.GetInt("endHour", 0), savedPref.GetInt("endMinute", 0), 0); TimeSpan nowTime = DateTime.Now.TimeOfDay; if (!((nowTime > startTime) && (nowTime < endTime))) { Console.WriteLine(startTime.Hours + ":" + startTime.Minutes + " " + endTime.Hours + ":" + endTime.Minutes); Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio ChronoFencing Alert") .SetContentText("Vehicle has been started outside of the preset timespan!") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); // Publish the notification: const int notificationId = 3; notificationManager.Notify(notificationId, notification); } else { alertedChronoFencing = false; } } } else if (events.EventType == EventType.Speed) { Console.WriteLine("Speeding!"); if (savedPref.GetBoolean("speed", true)) { Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio Notification") .SetContentText("Vehicle Speeding!") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); // Publish the notification: const int notificationId = 1; notificationManager.Notify(notificationId, notification); } } else if (events.EventType == EventType.FenceEntered) { Console.WriteLine("Fence Entered!"); if (alertedOutsideGeoFence) //If previously outside of fence { Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio GeoFencing Alert") .SetContentText("Vehicle has returned to the preset geofence perimeter") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); // Publish the notification: const int notificationId = 4; notificationManager.Notify(notificationId, notification); alertedOutsideGeoFence = false; } } else if (events.EventType == EventType.FenceExited) { Console.WriteLine("Fence Exited!"); Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio GeoFencing Alert") .SetContentText("Vehicle has left the preset geofence perimeter") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); // Publish the notification: const int notificationId = 2; notificationManager.Notify(notificationId, notification); alertedOutsideGeoFence = true; } else if (events.EventType == EventType.TripStatus) //If running { if (!(savedPref.GetInt("startHour", 25) == 25)) { TimeSpan startTime = new TimeSpan(savedPref.GetInt("startHour", 0), savedPref.GetInt("startMinute", 0), 0); TimeSpan endTime = new TimeSpan(savedPref.GetInt("endHour", 0), savedPref.GetInt("endMinute", 0), 0); TimeSpan nowTime = DateTime.Now.TimeOfDay; if (!((nowTime > startTime) && (nowTime < endTime))) //Not in timespan { Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio ChronoFencing Alert") .SetContentText("Vehicle is in motion outside of the preset timespan!") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); notification.Flags |= Android.App.NotificationFlags.OnlyAlertOnce; // Publish the notification: const int notificationId = 3; notificationManager.Notify(notificationId, notification); alertedChronoFencing = true; } else // In timespan { if (alertedChronoFencing) { Notification.Builder builder = new Notification.Builder(Application.Context) .SetContentTitle("Mojio ChronoFencing Alert") .SetContentText("Vehicle is now inside of the preset timespan!") .SetSmallIcon(Resource.Drawable.ic_logo); NotificationManager notificationManager = Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); Notification notification = builder.Build(); // Publish the notification: const int notificationId = 3; notificationManager.Notify(notificationId, notification); } alertedChronoFencing = false; } } } }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { // start a task here new Task(() => { new Task(() => { while (true) { if (DateTime.Now.ToString("dd/MM/yyyy").Equals(Utilities.GetFinishMonth().ToString("dd/MM/yyyy"))) { string title = "Hoy temina el mes de " + Utilities.GetMonthName(DateTime.Now); string contexto = "Siguiente mes " + Utilities.GetNextMonthName(DateTime.Now); Notification.Builder builder = new Notification.Builder(Android.App.Application.Context) .SetContentTitle(title) .SetContentText(contexto) .SetDefaults(NotificationDefaults.Sound) .SetSmallIcon(Resource.Drawable.logoIvaApp); builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); // Build the notification: Notification notification = builder.Build(); notification.Defaults |= NotificationDefaults.Vibrate; // Get the notification manager: NotificationManager notificationManager = Android.App.Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; // Publish the notification: const int notificationId = 0; notificationManager.Notify(notificationId, notification); } if (DateTime.Now.ToString("dd/MM/yyyy").Equals(new DateTime(DateTime.Now.Year, DateTime.Now.Month, 10).ToString("dd/MM/yyyy"))) { string title1 = "Pagar IVA"; string contexto1 = "Quedan 2 días para pagar " + Utilities.GetPrevMonthName(DateTime.Now); Notification.Builder builder1 = new Notification.Builder(Android.App.Application.Context) .SetContentTitle(title1) .SetContentText(contexto1) .SetDefaults(NotificationDefaults.Sound) .SetSmallIcon(Resource.Drawable.logoIvaAppBlanco); builder1.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); // Build the notification: Notification notification1 = builder1.Build(); builder1.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); // Get the notification manager: NotificationManager notificationManager1 = Android.App.Application.Context.GetSystemService(Context.NotificationService) as NotificationManager; // Publish the notification: const int notificationId1 = 0; notificationManager1.Notify(notificationId1, notification1); } Thread.Sleep(18000000); } //StopSelf(); }).Start(); }).Start(); return(StartCommandResult.Sticky); }
//protected override void OnError(Context context, string errorId) //{ // Log.Error(ApplicationSettings.AzureTag, "GCM Error: " + errorId); //} // protected override void OnRegistered(Context context, string registrationId) // { //PushNotificationImplementation.registerRequest.deviceToken = registrationId; //ApplicationSettings.DeviceToken = registrationId; ////added on 1/25/17 by aditmer to unregister the device if the registrationId has changed //CheckInstallationID.CheckNewInstallationID(registrationId); //Webservices.RegisterPush(PushNotificationImplementation.registerRequest); ////commented out on 11/29/16 by aditmer so we can register on the server // //RegistrationID = registrationId; // //Hub = new NotificationHub(NightscoutMobileHybrid.Constants.NotificationHubPath, NightscoutMobileHybrid.Constants.ConnectionString, context); // //try // //{ // // Hub.UnregisterAll(registrationId); // //} // //catch (Exception ex) // //{ // // Log.Error(ApplicationSettings.AzureTag, ex.Message); // //} // //var tags = new List<string>() { ApplicationSettings.AzureTag }; // //try // //{ // // const string templateBodyGCM = "{\"data\":{\"message\":\"$(message)\",\"eventName\":\"$(eventName)\",\"group\":\"$(group)\",\"key\":\"$(key)\",\"level\":\"$(level)\",\"sound\":\"$(sound)\",\"title\":\"$(title)\"}}"; // // var hubRegistration = Hub.RegisterTemplate(registrationId, "nightscout", templateBodyGCM, tags.ToArray()); // //} // //catch (Exception ex) // //{ // // Log.Error(ApplicationSettings.AzureTag, ex.Message); // //} //} //protected override void OnUnRegistered(Context context, string registrationId) //{ // createNotification("0", "GCM Unregistered...", "The device has been unregistered!", 0,"0","0"); //} void createNotification(string key, string title, string desc, int sound, string group, string level) { var intent = new Intent(this, typeof(MainActivity)); intent.AddFlags(ActivityFlags.SingleTop); var pendingIntent = PendingIntent.GetActivity(this, 0, intent, PendingIntentFlags.UpdateCurrent); //addd on 12/5/16 by aditmer to add actions to the push notifications AckRequest ack = new AckRequest(); ack.group = group; ack.key = key; ack.level = level; ack.time = ApplicationSettings.AlarmUrgentMins1; var notificationIntent = new Intent(this, typeof(NotificationActionService)); notificationIntent.PutExtra("ack", JsonConvert.SerializeObject(ack)); var snoozeIntent1 = PendingIntent.GetService(this, 0, notificationIntent, PendingIntentFlags.OneShot); //adds 2nd action that snoozes the alarm for the ApplicationSettings.AlarmUrgentMins[1] amount of time var notificationIntent2 = new Intent(this, typeof(NotificationActionService)); AckRequest ack2 = new AckRequest(); ack2.group = group; ack2.key = key; ack2.level = level; ack2.time = ApplicationSettings.AlarmUrgentMins2; notificationIntent2.PutExtra("ack", JsonConvert.SerializeObject(ack2)); var snoozeIntent2 = PendingIntent.GetService(this, 0, notificationIntent2, PendingIntentFlags.OneShot); //Notification.Action notificationAction = new Notification.Action(0, "Snooze", snoozeIntent); var notificationBuilder = new Notification.Builder(this); if (Build.VERSION.SdkInt >= BuildVersionCodes.O) { notificationBuilder.SetChannelId("nightscout"); } notificationBuilder.SetSmallIcon(NightscoutMobileHybrid.Droid.Resource.Drawable.icon); notificationBuilder.SetContentTitle(title); notificationBuilder.SetContentText(desc); notificationBuilder.SetAutoCancel(true); notificationBuilder.SetPriority((int)NotificationPriority.Max); notificationBuilder.SetContentIntent(pendingIntent); notificationBuilder.AddAction(0, $"Snooze {ack.time} min", snoozeIntent1); notificationBuilder.AddAction(0, $"Snooze {ack2.time} min", snoozeIntent2); if (sound == 0) { notificationBuilder.SetDefaults(NotificationDefaults.Vibrate | NotificationDefaults.Lights | NotificationDefaults.Sound); } else { notificationBuilder.SetDefaults(NotificationDefaults.Vibrate | NotificationDefaults.Lights); notificationBuilder.SetSound(Android.Net.Uri.Parse(ContentResolver.SchemeAndroidResource + "://" + PackageName + "/Raw/" + sound)); } var notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); var notification = notificationBuilder.Build(); if (sound != 0) { notification.Flags = NotificationFlags.Insistent; } notificationManager.Notify(key, 1, notification); //Not using in-app notifications (Nightscout handles all of that for us) //dialogNotify(title, desc); }
public override StartCommandResult OnStartCommand(Intent intent, StartCommandFlags flags, int startId) { var prefs = GetSharedPreferences("KiedyTest", FileCreationMode.Private); int req_timeout = prefs.GetInt("connection_timeout", 0); string heartbeat_url = "http://dziennik.zs1debica.pl/kiedytest/android/request_handler/heartbeat.php?app_type=uczen&app_version=1.0"; ////// HEARTBEAT EXCUTER /////// _timer = new Timer(o => { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(heartbeat_url); request.Timeout = req_timeout; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; if (response.CharacterSet == null) { readStream = new StreamReader(receiveStream); } else { readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); } data = readStream.ReadToEnd(); response.Close(); readStream.Close(); } network_ok = true; } catch (WebException ex) { network_ok = false; } }, null, 0, 60000); /// Koniec timera /////////////////////////////// string content, content2; string user_name = prefs.GetString("login", null); string user_password = prefs.GetString("password", null); string urlAddress = "http://dziennik.zs1debica.pl/kiedytest/android/request_handler/get_planned_test_notification.php?user_name=" + user_name + "&user_password="******"notify_enabled", null); if (notify_enabled == "yes") { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress); request.Timeout = req_timeout; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { Stream receiveStream = response.GetResponseStream(); StreamReader readStream = null; if (response.CharacterSet == null) { readStream = new StreamReader(receiveStream); } else { readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet)); } data = readStream.ReadToEnd(); response.Close(); readStream.Close(); } network_ok = true; } catch (WebException ex) { network_ok = false; } content2 = data; ////////////////////////// if (network_ok) { content = data; try { content = content.Replace("\x00", ""); // // AWESOME !!!!! // in my case I want to see it, otherwise just replace with "" MemoryStream memStream = new MemoryStream(); byte[] data2 = System.Text.Encoding.UTF8.GetBytes(content); memStream.Write(data2, 0, data2.Length); memStream.Position = 0; XmlDocument doc = new XmlDocument(); doc.LoadXml(content); string noti_type; int noti_type_INT; noti_type_INT = 0; string noti_test_id; noti_test_id = null; int noti_test_id_INT; noti_test_id_INT = 0; string noti_pending; noti_pending = null; int noti_pending_INT; noti_pending_INT = 0; noti_type = "kot"; int c = 0; string noti_body; noti_body = null; string vibration, sound; vibration = null; sound = null; int vibration_INT, sound_INT; vibration_INT = 0; sound_INT = 0; foreach (XmlElement x in doc.SelectNodes("notification/notification_data/notification_type")) { c++; noti_type = x.InnerXml; Console.Write(x.InnerXml); } ////// Checking if any notifications available //////// foreach (XmlElement x in doc.SelectNodes("notification/notification_data/pending_notifications_count")) { c++; noti_pending = x.InnerXml; Console.Write(x.InnerXml); } ////// Checking test id //////// foreach (XmlElement x in doc.SelectNodes("notification/notification_data/test_id")) { c++; noti_test_id = x.InnerXml; Console.Write(x.InnerXml); } ////// Checking notification text //////// foreach (XmlElement x in doc.SelectNodes("notification/notification_data/notification_body")) { c++; noti_body = x.InnerXml; Console.Write(x.InnerXml); } ////// Checking if user enabled sound //////// foreach (XmlElement x in doc.SelectNodes("notification/notification_data/sound")) { c++; sound = x.InnerXml; Console.Write(x.InnerXml); } ////// Checking if user enabled vibration //////// foreach (XmlElement x in doc.SelectNodes("notification/notification_data/vibration")) { c++; vibration = x.InnerXml; Console.Write(x.InnerXml); } /// Converting variables////////////////// int.TryParse(noti_pending, out noti_pending_INT); int.TryParse(noti_type, out noti_type_INT); //int.TryParse(noti_test_id, out noti_test_id_INT); int.TryParse(sound, out sound_INT); int.TryParse(vibration, out vibration_INT); /////////////////////////////////////// if (noti_pending_INT > 0) { /// DATA FOR OTHER ACTIVITY/// int test_id; int randomcount; // float count2; // count2 = 08.06f; test_id = noti_test_id_INT; Bundle valuesForActivity = new Bundle(); valuesForActivity.PutString("test_id", noti_test_id); if (noti_type_INT == 1) { valuesForActivity.PutString("display_type", "onlyone"); } if (noti_type_INT == 2) { if (noti_pending_INT > 1) { valuesForActivity.PutString("display_type", "all"); } else { valuesForActivity.PutString("display_type", "onlyone"); } } // When the user clicks the notification, SecondActivity will start up. Intent resultIntent = new Intent(this, typeof(Activity1)); // Pass some values to SecondActivity: resultIntent.PutExtras(valuesForActivity); // Construct a back stack for cross-task navigation: TaskStackBuilder stackBuilder = TaskStackBuilder.Create(this); stackBuilder.AddParentStack(Java.Lang.Class.FromType(typeof(Activity1))); stackBuilder.AddNextIntent(resultIntent); // Create the PendingIntent with the back stack: PendingIntent resultPendingIntent = stackBuilder.GetPendingIntent(0, PendingIntentFlags.UpdateCurrent); ///////////////////////////////////////////////////////////////////////////////// if (noti_type_INT == 1) { // Build the notification: Notification.Builder builder = new Notification.Builder(this) .SetAutoCancel(true) // Dismiss from the notif. area when clicked .SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked. .SetContentTitle("Nowy zapowiedziany test!") // Set its title // .SetNumber(count) // Display the count in the Content Info .SetSmallIcon(App7.Resource.Drawable.Icon) // Display this icon .SetContentText(String.Format( noti_body)); // The message to display. // Finally, publish the notification: NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); Random rand1 = new Random(); randomcount = rand1.Next(); if (sound_INT == 1 && vibration_INT == 1) { builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); } else if (sound_INT == 1) { builder.SetDefaults(NotificationDefaults.Sound); } else if (vibration_INT == 1) { builder.SetDefaults(NotificationDefaults.Vibrate); } // builder.SetDefaults( NotificationDefaults.Vibrate); notificationManager.Notify(randomcount, builder.Build()); } if (noti_type_INT == 2) { string new_test_parsed_title; if (noti_pending_INT > 1) { new_test_parsed_title = "Nowe zapowiedziane testy!"; } else { new_test_parsed_title = "Nowy zapowiedziany test!"; } // Build the notification: Notification.Builder builder = new Notification.Builder(this) .SetAutoCancel(true) // Dismiss from the notif. area when clicked .SetContentIntent(resultPendingIntent) // Start 2nd activity when the intent is clicked. .SetContentTitle(new_test_parsed_title) // Set its title // .SetNumber(count) // Display the count in the Content Info .SetSmallIcon(App7.Resource.Drawable.Icon) // Display this icon .SetContentText(String.Format( noti_body)); // The message to display. // Instantiate the Big Text style: Notification.BigTextStyle textStyle = new Notification.BigTextStyle(); // Fill it with text: string longTextMessage = noti_body; // longTextMessage += " / Just like me. "; //... textStyle.BigText(longTextMessage); // Set the summary text: if (noti_pending_INT == 1) { tests_grammar = " nowy zapowiedziany test"; } if (noti_pending_INT > 1 && noti_pending_INT < 5) { tests_grammar = " nowe zapowiedziane testy"; } if (noti_pending_INT > 5) { tests_grammar = " nowych zapowiedzianych testów"; } textStyle.SetSummaryText(noti_pending + tests_grammar); // Plug this style into the builder: builder.SetStyle(textStyle); // Finally, publish the notification: NotificationManager notificationManager = (NotificationManager)GetSystemService(Context.NotificationService); Random rand1 = new Random(); randomcount = rand1.Next(); if (sound_INT == 1 && vibration_INT == 1) { builder.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); } else if (sound_INT == 1) { builder.SetDefaults(NotificationDefaults.Sound); } else if (vibration_INT == 1) { builder.SetDefaults(NotificationDefaults.Vibrate); } // builder.SetDefaults( NotificationDefaults.Vibrate); notificationManager.Notify(randomcount, builder.Build()); } } } catch (Exception ex) { // just suppress any error logging exceptions } } /// IF network ok END } }, null, 0, TimerWait); /// Koniec timera return(START_STICKY); }
public override void OnReceive(Context context, Intent intent) { var message = intent.GetStringExtra("message"); var title = intent.GetStringExtra("title"); var id = intent.GetStringExtra("id"); if (title == "Um Minuto de Presença") { id = id.Remove(id.Length - 1); var notIntent = new Intent(context, typeof(MainActivity)); var contentIntent = PendingIntent.GetActivity(context, 0, notIntent, PendingIntentFlags.CancelCurrent); var manager = NotificationManagerCompat.From(context); SQLite_Android sqlite = new SQLite_Android(); PlatformNotifier pf = new PlatformNotifier(); NotificacaoDAO dao = new NotificacaoDAO(sqlite.GetConnection(), pf); ObservableCollection <Notificacao> notificacoes = dao.Notificacoes; var numero = Convert.ToInt32(id); var notificacao = (from not in notificacoes where not.ID == numero select not).FirstOrDefault <Notificacao>(); if (!notificacao.Repetir) { dao.DesativarNotificacao(notificacao); } //gerando notificacao para disparo var builder = new Notification.Builder(context) .SetContentIntent(contentIntent) .SetSmallIcon(Resource.Drawable.ic_notification) .SetContentTitle(title) .SetContentText(message) .SetWhen(Java.Lang.JavaSystem.CurrentTimeMillis()) .SetAutoCancel(true); if (notificacao.Vibrar) { builder.SetDefaults(NotificationDefaults.Vibrate); } if (notificacao.Som) { builder.SetSound(Android.Net.Uri.Parse("android.resource://" + context.ApplicationContext.PackageName + "/Raw/" + Resource.Raw.som_notificacao)); } var notification = builder.Build(); manager.Notify(0, notification); } else { SQLite_Android sqlite = new SQLite_Android(); PlatformNotifier pf = new PlatformNotifier(); NotificacaoDAO dao = new NotificacaoDAO(sqlite.GetConnection(), pf); ObservableCollection <Notificacao> notificacoes = dao.Notificacoes; for (int i = 0; i < notificacoes.Count; i++) { if (notificacoes[i].Ativado) { dao.AtivarNotificacao(notificacoes[i]); } } } }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); Intent intent; SupportFragment newFragment = new Hub(); var trans = SupportFragmentManager.BeginTransaction(); trans.Add(Resource.Id.flContent, newFragment, "Hub"); trans.Commit(); mDrawerLayout = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); navigationView = FindViewById <NavigationView>(Resource.Id.nav_view); View navheader = navigationView.GetHeaderView(0); CircleImageView iv = (CircleImageView)navheader.FindViewById(Resource.Id.imageCustomerIcon); iv.Click += delegate { intent = new Intent(this, typeof(Profile)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); }; await LoadAccount(); navigationView.NavigationItemSelected += (sender, e) => { SupportFragment frag; e.MenuItem.SetChecked(true); switch (e.MenuItem.ItemId) { case (Resource.Id.nav_hub): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Hub"); newFragment = new Hub(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Hub"); if (frag == null) { trans.AddToBackStack("Hub"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_tournament): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Turnieje"); newFragment = new Tournament(null, null, null, null, null); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Turnieje"); if (frag == null) { trans.AddToBackStack("Turnieje"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_quickgame): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Szybka gra"); newFragment = new Quickgame(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Szybka gra"); if (frag == null) { trans.AddToBackStack("Szybka gra"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_findplayers): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Znajdz gracza"); newFragment = new Findplayers(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Znajdz gracza"); if (frag == null) { trans.AddToBackStack("Znajdz gracza"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_friends): frag = (SupportFragment)SupportFragmentManager.FindFragmentByTag("Znajomi"); newFragment = new FriendList(); trans = SupportFragmentManager.BeginTransaction(); trans.Replace(Resource.Id.flContent, newFragment, "Znajomi"); if (frag == null) { trans.AddToBackStack("Znajomi"); } trans.Commit(); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); break; case (Resource.Id.nav_profile): intent = new Intent(this, typeof(Profile)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); break; case (Resource.Id.nav_addQuickgame): intent = new Intent(this, typeof(AddQuickgame)); OverridePendingTransition(Resource.Animation.animRight, Resource.Animation.animRight2); this.StartActivity(intent); break; default: break; } mDrawerLayout.CloseDrawers(); }; pref = ((AppCompatActivity)this).GetSharedPreferences(Notyfication, FileCreationMode.Private); string noty = pref.GetString("Notification", ""); if (noty == "yes") { pref = ((AppCompatActivity)this).GetSharedPreferences(runActivity, FileCreationMode.Private); bool run = pref.GetBoolean("MainActivity", false); if (run) { Intent notint = new Intent(this, typeof(MainActivity)); notint.SetFlags(ActivityFlags.ClearTop); notint.SetFlags(ActivityFlags.NewTask); const int pendingIntentId = 0; PendingIntent pendingIntent = PendingIntent.GetActivity(this, pendingIntentId, notint, PendingIntentFlags.OneShot); var notification = new Notification.Builder(this); notification.SetContentIntent(pendingIntent); notification.SetContentText("Zaproszenie do gry"); notification.SetContentTitle("GameHub"); notification.SetSmallIcon(Resource.Drawable.Icon4); notification.SetAutoCancel(true); notification.SetDefaults(NotificationDefaults.Sound | NotificationDefaults.Vibrate); NotificationManager NotManager = (NotificationManager)GetSystemService(Context.NotificationService); NotManager.Notify(0, notification.Build()); } else { } } }