'Cant create an alarm in Xamerin Android C#

Copied my teacher's simplified code in order to see if the code i wrote was wrong or somthing yet even her's isnt working. Here is it:

private void BtnAlarm_Click(object sender, EventArgs e)
 {
            Intent intentAlarm = new Intent(this, typeof(AlarmReceiver));
            // #2 - Pending intent - > Broadcast
            PendingIntent pendingIntent = PendingIntent.GetBroadcast(Application.Context, 1, intentAlarm, 0);
            // #3 - Set Alarm Manager
            AlarmManager alarmManager = (AlarmManager)GetSystemService(AlarmService);
            //30s
            alarmManager.SetExactAndAllowWhileIdle(AlarmType.ElapsedRealtimeWakeup, 
            SystemClock.ElapsedRealtime() + 30 * 1000, pendingIntent);
        }

The debugger wont run onto this activity:

public class AlarmReceiver : BroadcastReceiver
    {
        public override void OnReceive(Context context, Intent intent)
        {
            Toast.MakeText(context, "Received intent!", ToastLength.Short).Show();
        }
    }

Just to be clear, while running her app the alarm was working.



Solution 1:[1]

You could use the code below with your AlarmReceiver:

 [BroadcastReceiver(Enabled = true, Exported = false)]
public class AlarmReceiver : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        Toast.MakeText(context, "Received intent!", ToastLength.Short).Show();
    }

}

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wendy Zang - MSFT