How To Create Alarm Clock In Android Studio? 4 Effective Methods!

Creating a customized alarm clock has never been so difficult with the help of android studio. Not just app developers, even android users with no technology background can complete this task with ease.


So, how to create alarm clock in android studio? That’s the puzzle we will be solving in this article. No worries, the explanation is simple and easy-peasy to implement for any beginner.


Whether you are an app developer looking for ways to improve an alarm clock or just a creative user who loves to customize everything according to his needs, this article will surely come in handy for you.


Well, then what are we waiting for?


The Features We Want In This Alarm App


In this android studio alarm clock tutorial, we will try to maintain simplicity. That being said, you can add fancy buttons and layouts if you want to. But we will only show how the basic setup should be done. The app we are creating today will have the following features:


  • You can set only once or a recurring alarm.


  • Your favorite ringtone will start playing as a notification for alarm.


  • You can snooze the alarm or turn it off completely.


  • The vibrating option will also be available along with the ringtone.


  • It can be digital (only the time will appear) or analog (a spinning clock).


Okay, so now that we are clear about the results, let’s jump into the actual android alarm clock app tutorial.


How to Create Alarm Clock in Android Studio?


A simple alarm clock app has two interfaces for the user. First of all, we have a fragment that showcases a list of existing alarm schedules of the phone with a button for creating new ones.


And the second fragment will be used only when the user wants to snooze or turn off the alarm. We need certain tools for this procedure in the android studio. It includes Time picker, alarm manager, media player, and broadcast receiver. How these tools are to be used?


Let’s elaborate on the exact function of these tools and how to use them to create an android alarm clock.


1. Time Picker


The clock in the alarm app is actually pretty simple to make. The clock is used for selecting an exact time to create alarm. Luckily, time picker does it all for you. And if you want to set a date too which is available in many alarm apps, this tool will be useful for that too.


But before that make sure you have set up the android studio environment by giving the project a name, and a company domain. Once you do that, we have to write some XML code. Once you choose the XML format, it shows a blank layout to you.


Now we will edit the XML layout and give instructions regarding the color of texts, background, text font, size, etc. See the photo below and edit similarly.


The next step would be to select the date and time widgets from the menu and click into the “textcheck.” Drag the text to your new layout window and it will automatically become a spinning clock.




how to create alarm clock in android studio




The clock will show the time on your phone at that moment by default. Suppose, it is 7.47 pm. The clock will be at 7.47 too. Don’t get confused if the time differs from your windows operating system.


Moving on, go to the settings and locate “date and time.” here you can select the format of time. Whether you want the clock to show international time (24 hours) or the format in your home country (12 hours) can be decided through this option.


2. Alarm Manager (To Schedule The Alarm)


Next up is the alarm manager. Through this, we can create buttons like “cancel the alarm” or “snooze it for 5 mins.” And most importantly alarm manager monitors the alarm and sends a signal to the broadcast receiver to notify us.


It can detect whether an alarm is created for a recurring purpose or not. So it records the recurring alarm time and notifies us on that time always. However, if the alarm is created for a one-time purpose, the alarm manager erases the record after reminding us only one time.


Moving back to our XML code, we will create a “button” and specify the text, height, width, color of the buttons. So if we want the button to cancel alarms, we will write (android: text=”cancel alarm”). The excerpt should look like this after you put the instructions correctly.




how to create alarm clock in android studio




3. Broadcast Receiver


In the third section, we will enable the alarm manager to trigger the broadcast receiver when it’s time for the alarm to go off. The broadcast receiver’s typical job is notifying the user of certain events.


For example, we hear vibration whenever a new message arrives, the microphone is plugged in/plugged out or wi-fi connectivity changes, and so on. The broadcast receiver is behind all of this.


It is a very simple application. All you have to do is provide some permission regarding whether to vibrate while notifying or not and how many milliseconds should the app wait after an alarm goes off.


For that, we will use “integer” text. Here {int= Integer, parseInt(text.getText(), toString()} is the first phrase. And after that, follow the pic below and describe the objective of this phrase to the broadcast receiver.




how to create alarm clock in android studio




Here, the pending integer deals with how many milliseconds the receiver will have to wait. And the “set” section is used to set the time when the user receives a notification. The formula used here is (i+1000). We are using 1000 because the unit is in milliseconds.


So once the timer goes off and the pre-determined milliseconds have passed, the notification will be sent through this receiver.


4. Alarm Manager (To Turn Off the Alarm)


In the fourth stage, we will be using the alarm manager again to dismiss or re-schedule the alarm. To create such “buttons” we will follow the second stage. And then we will specify the objective of these buttons through codes.


We will start with a private void cancel alarm(){


And then fill up the section by specifying the intent. Follow the pic below and copy it without any mistakes.




how to create alarm clock in android studio





Frequently Asked Questions (F.A.Q’s):


1. How to Set Alarm on Android?


Go into the “clock” app> check into “create a new alarm”> spin the clock and select the time you want> specify AM or PM> press “Okay.” And that’s how you have created a new alarm in your android device.


2. How to Make an Alarm Clock App?


You can make a simple alarm clock using the android studio. All you need is some tools for help: time picker, alarm manager, media player, and broadcast receiver.


3. How to Change the Alarm Ringtone?


For that, go to the android’s settings and locate “sound and vibration.” Now, select “alarm sound” and a list of ringtones will pop up in front of you. You can tap on any of them to finalize it.





In this article, we explained the manual process in the best way possible. Instead of typing these codes by yourself, you can buy the codes if you really want. They are ready to paste and don’t require any effort on your part.


However, if you want to customize it according to your wish, just stick with this method. Hope you understood how to create alarm clock in android studio.


You may also be interested to know:


How Do I Set An Alarm Every 2 Hours On My Android?

How Do I Schedule An Alarm Every One Hour On An Android?

How to Cancel or Delete an Alarm on Android

How To Delete All Alarms At Once On iPhone And Android?

Leave a Reply

Your email address will not be published.