protected void CreateTrigger() { Switch toggleButton1 = FindViewById <Switch> (Resource.Id.toggleButton1); Switch withRange = FindViewById <Switch> (Resource.Id.times); // TimePicker start = FindViewById<TimePicker> (Resource.Id.early); // TimePicker late = FindViewById<TimePicker> (Resource.Id.late); EditText msg = FindViewById <EditText> (Resource.Id.message); if (toggleButton1.Activated || toggleButton1.Checked) { Action <Activity> a; if (withRange.Checked) { int h0 = hour; int hn = minute; int m0 = hour2; int mn = minute2; Android.Util.Log.Info("num1" + h0, "num2" + m0); a = delegate(Activity obj) { DateTime time = new DateTime(); if (time.Hour >= h0 && time.Hour < hn && time.Minute >= m0 && time.Minute < mn) { NotificationManager notificationManager = obj.GetSystemService(Context.NotificationService) as NotificationManager; var n = new Notification.Builder(obj) .SetContentTitle("Mind you?") .SetContentText(msg.Text) .SetSmallIcon(Resource.Drawable.Icon) .SetPriority((int)NotificationPriority.Max) .SetDefaults(NotificationDefaults.Vibrate); notificationManager.Notify(id, n.Build()); } Android.Util.Log.Info("num1" + h0, "num2" + m0); }; } else { a = delegate(Activity obj) { NotificationManager notificationManager = obj.GetSystemService(Context.NotificationService) as NotificationManager; var n = new Notification.Builder(obj) .SetContentTitle("Mind you?") .SetContentText(msg.Text) .SetSmallIcon(Resource.Drawable.Icon) .SetPriority((int)NotificationPriority.High) .SetDefaults(NotificationDefaults.Vibrate); notificationManager.Notify(id, n.Build()); }; } LogReader.AddCallback(this.app, a); } else { LogReader.RemoveCallback(this.app); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // ernesto var l = new LogReader(); System.Threading.Tasks.Task.Factory.StartNew(l.TryLogs); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // ImageView view = FindViewById<ImageView> (Resource.Id.frontImage); // view.SetImageResource (Resource.Drawable.Icon); LogReader.SetActivity(this); Button appN = FindViewById <Button> (Resource.Id.appNotification); Button webN = FindViewById <Button> (Resource.Id.webNotification); appN.Click += delegate { StartActivity(typeof(Conditionals.ConditionalPicker)); }; webN.Click += delegate { StartActivity(typeof(Chrome)); }; //StartActivity(typeof(AppChooserActivity)); //StartActivity(typeof(Chrome)); //this.ApplicationContext.StartService (); ActionBar.SetDisplayShowHomeEnabled(true); ActionBar.SetDisplayShowTitleEnabled(true); // ActionBar.SetCustomView (Resource.Layout.loweractionbar); // ActionBar.SetDisplayShowCustomEnabled (true); }