} // We need a default constructor if the system decides to call on this receiver public override void OnReceive(Context context, Intent intent) { Android.Support.V7.App.AlertDialog assist; switch (ResultCode) { //if we receive an OK status it means that our sms has been sent successfully case Result.Ok: //Make sure that this is the manually initialized from the activity Receiver and not the system initialized one if (Context == null) { break; } //Grab the file to add the sms sent TextsPerDay texts = new TextsPerDay(Context); texts.AddToCount(); //set the timer to 3 hours ahead sentAt = DateTime.Now.AddHours(3); //Notify the user that his request has been successfully sent to 13033 assist = new Android.Support.V7.App.AlertDialog.Builder(Context) .SetTitle(Resource.String.Attention).SetMessage(Context.Resources.GetString(Resource.String.AttentionMessage) + " " + sentAt.ToString("hh:mm")).SetPositiveButton(Resource.String.OK, (object o, DialogClickEventArgs arg) => { //ask the user if he wants to be alerted view = ((Activity)Context).LayoutInflater.Inflate(Resource.Layout.AlertDialog, null); ListView list = view.FindViewById <ListView>(Resource.Id.AlertList); list.Adapter = new ArrayAdapter <string>(Context, Android.Resource.Layout.SimpleListItem1, new string[] { "15 " + Context.Resources.GetString(Resource.String.mins), "30 " + Context.Resources.GetString(Resource.String.mins), "1 " + Context.Resources.GetString(Resource.String.Hour) }); list.ItemClick += List_ItemClick; alertDialog = new Android.Support.V7.App.AlertDialog.Builder(Context).SetTitle(Resource.String.AlertTitle) .SetMessage(Resource.String.AlertMessage).SetView(view) .SetNegativeButton(Resource.String.Abort, (object o, DialogClickEventArgs e) => { }).Show(); }).Show(); break; default: //Make sure that this is the manually initialized from the activity Receiver and not the system initialized one if (Context == null) { break; } //Alert the user that something went wrong assist = new Android.Support.V7.App.AlertDialog.Builder(Context) .SetTitle(Resource.String.Error).SetIcon(Resource.Drawable.Error).SetMessage(Resource.String.SmsFailed).SetPositiveButton(Resource.String.OK, (object o, DialogClickEventArgs arg) => { }).Show(); break; } }
public void EnableTimer() { //Grab the file to add the sms sent TextsPerDay texts = new TextsPerDay(this); texts.AddToCount(); //set the timer to 3 hours ahead sentAt = DateTime.Now.AddHours(3); //Notify the user that his request has been successfully sent to 13033 Android.Support.V7.App.AlertDialog assist = new Android.Support.V7.App.AlertDialog.Builder(this) .SetTitle(Resource.String.Attention).SetMessage(Resources.GetString(Resource.String.AttentionMessage) + " " + sentAt.ToString("hh:mm")).SetPositiveButton(Resource.String.OK, (object o, DialogClickEventArgs arg) => { //ask the user if he wants to be alerted view = LayoutInflater.Inflate(Resource.Layout.AlertDialog, null); ListView list = view.FindViewById <ListView>(Resource.Id.AlertList); list.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, new string[] { "15 " + Resources.GetString(Resource.String.mins), "30 " + Resources.GetString(Resource.String.mins), "1 " + Resources.GetString(Resource.String.Hour) }); list.ItemClick += List_ItemClick; alertDialog = new Android.Support.V7.App.AlertDialog.Builder(this).SetTitle(Resource.String.AlertTitle) .SetMessage(Resource.String.AlertMessage).SetView(view) .SetNegativeButton(Resource.String.Abort, (object o, DialogClickEventArgs e) => { }).Show(); }).Show(); }