public class MainActivity extends AppCompatActivity {
  private AlarmManager alarmManager;
  private PendingIntent pendingIntent;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Button btnSetAlarm = findViewById(R.id.btnSetAlarm);
    btnSetAlarm.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        setAlarm();
      }
    });
    Button btnCancelAlarm = findViewById(R.id.btnCancelAlarm);
    btnCancelAlarm.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        cancelAlarm();
      }
    });
  }
  private void setAlarm() {
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    calendar.set(Calendar.HOUR_OF_DAY, 8); // set alarm jam 8 pagi
    calendar.set(Calendar.MINUTE, 0);
    Intent intent = new Intent(MainActivity.this, AlarmReceiver.class);
    pendingIntent = PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0);
    alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
  }
  private void cancelAlarm() {
    if (alarmManager != null && pendingIntent != null) {
      alarmManager.cancel(pendingIntent);
    }
  }
}
```
3. Broadcast Receiver (AlarmReceiver.java):
Buatlah kelas `AlarmReceiver.java` yang akan menerima pesan ketika alarm berbunyi.