Page 1 of 1

JAVA Android-Programm / "alarm clock app" Topics: Activities, Broadcasts, AlarmManager, PendingIntents An alarm clock a

Posted: Sat May 14, 2022 3:40 pm
by answerhappygod
JAVA
Android-Programm / "alarm clock app"
Topics: Activities, Broadcasts, AlarmManager,
PendingIntents
An alarm clock app is to be developed. The app provides a main
activity that can be used to create an alarm. The main activity
contains a time picker that can be used to set the alarm time.
Also, there are two Button to set and cancel the alarm.
Once the alarm occurs, the user is presented with a second activity
that includes a snooze button. If the user presses snooze, the
alarm goes off by one configurable time pushed back (the snooze
time can be set in a PreferenceActivity and should be
persisted).
After the user clicks Snooze, the activity closes and a
notification appears showing the new alarm time. If the user clicks
on the notification, the main activity opens again, in which the
alarm can be canceled.
As soon as the alarm occurs, a sound should be played. The sound is
designed to play until the user hits snooze or cancels the
alarm.
Note 1: Sound files are placed in the res/raw folder. Using and
playing sounds is shown in the code section below.
MediaPlayer player = MediaPlayer.create(context,
R.raw.alarm);
player.setLooping(true);
player.start();
SystemClock.sleep(20000);
player.stop();