Alarm Manager SetAlarmClock

Hi Good day, i have a problem with the "long" from "SetAlarmClock", what i want to do it's get the time with a "TimePiker", and set in the alarmManager.

Now im trying like this:

    private void AlarmOn_Click(object sender, EventArgs e)
                {
                    try
                    {
                        alarmTimePicker = FindViewById<TimePicker>(Resource.Id.timePicker1);
                       SaveAlarm.dateOfAlarm = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, alarmTimePicker.Hour,                           alarmTimePicker.Minute, 0);
    
                    text1.Text = "Alarm On";
                    Intent myIntent = new Intent(ApplicationContext, typeof(AlarmReciver));
                    PendingIntent pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, myIntent, 0);
        
                    
                    long milliseconds = SaveAlarm.dateOfAlarm.Ticks / TimeSpan.TicksPerMillisecond;
                    
                    AlarmManager.AlarmClockInfo fuuu= new AlarmManager.AlarmClockInfo(milliseconds, pendingIntent);
                    alarmManager.SetAlarmClock(fuuu, pendingIntent);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
}

i tryit without TimeSpan but dosen't work for me :(
Receiver:

[BroadcastReceiver]
public class AlarmReciver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Android.Net.Uri notification = RingtoneManager.GetDefaultUri(RingtoneType.Alarm);
Ringtone r = RingtoneManager.GetRingtone(Application.Context, notification);
r.Play();
}
}

if someone can help me, I would be very grateful!
Thanks you all and sorry for my english!!

Answers

  • avillarubiaavillarubia Member ✭✭

    anyone? we have some issues, this thread was created a long time ago

Sign In or Register to comment.