How to create a simple Alarm Clock App in Android Studio? - complete steps

  Рет қаралды 87,571

Programmer World

Programmer World

Күн бұрын

This video shows complete steps and demo to design and develop an Alarm clock App using Android Studio.
Complete source code is available at below link:
programmerworld.co/android/cr...
We will be glad to hear from you regarding any query, suggestions or appreciations at: programmerworld1990@gmail.com

Пікірлер: 80
@dcclyde575
@dcclyde575 3 жыл бұрын
I trust that accent. Its gold when talking about IT and computers. Indians are very smart people.
@Vegybin
@Vegybin 3 жыл бұрын
kinda lol
@toxillo
@toxillo 3 жыл бұрын
Looks to me like he is advising people to build an alarm app by checking every second if it should ring yet. That sounds terrible. It will be extremely taxing on the battery and the proccessor load for a simple alarm app.
@uxaines8910
@uxaines8910 2 жыл бұрын
1 % of talant and 99% of practicing
@drashtybatavia8035
@drashtybatavia8035 5 жыл бұрын
Heyy, thanks for making this video. It helped a lot to me!!!!
@jumpjumpjump3499
@jumpjumpjump3499 4 жыл бұрын
thank you so much
@oraseus90
@oraseus90 5 жыл бұрын
I don't have date under palette
@derekthomas9850
@derekthomas9850 3 жыл бұрын
hey i think the one error would be an alarm will not work from midnight to 12:59am. This is because the military time is 0 hours and trying to compare with 12. I had this issue and right now am trying to resolve
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Thanks for your comment Derek. This short video is just to quickly show how to implement a basic alarm clock. This video should be only a starting step. For a real App, lots of customization and robustness in the code needs to be implemented. Cheers Programmer World programmerworld.co -
@owen18lazaret
@owen18lazaret 4 жыл бұрын
Great video, the app is running great in the android studio but when open on my phone it doesn't work anymore, I mean it opens but the alarm doesn't ring, any fix for that?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
See in this tutorial App, only thing it is doing is comparing the system/actual time with the set time in the alarm clock. If it matches then it plays/invokes ringtone of your phone. So, if it is not working on your real phone then probably the system time which your phone is giving to App is in a different format than alarm time format received from clock. Very unlikely as mostly Android OS controls both of these formats. But certain OEMs may put a wrapper around original Android OS which may be causing it. It may be difficult to debug this situation, so I will recommend that you use toast command to display the two times while they are matched and then manually verify whether match is successful. Other reason could be that ringtone of your phone is either not set or is in silent mode/very low volume. Just check on that part as well. Lastly, I will recommend you can watch subsequent part of these tutorials using below links and try that code: kzfaq.info/get/bejne/iM1_pNCCyN_JpZ8.html kzfaq.info/get/bejne/g7idabGYv9LRdJc.html In case needed, complete source code of this tutorial is available at below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio Hope it works. Good Luck Programmer World programmerworld.co -
@owen18lazaret
@owen18lazaret 4 жыл бұрын
@@ProgrammerWorld thank you so much for your quick response, I will look into it. Thanks
@sandipmajumder120
@sandipmajumder120 5 жыл бұрын
yOU ARE AWESEOME PELASE MAKE MORE VIDEOS!
@prathameshjadhav5212
@prathameshjadhav5212 4 жыл бұрын
How to make application run in backend even if we close the application it should ring like something?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
For that you will have to implement AlarmManager which sends a broadcast using Setrepeat call. And then you will have to implement broadcast receiver to receive the broadcast action and perform specific action like playing alarm in this case. Cheers Programmer World programmerworld.co -
@nhatnamdao2916
@nhatnamdao2916 3 жыл бұрын
BRO HES THE GUYYY
3 жыл бұрын
hey guy,thank your video, can you tell me how to make it works every day??? i used repeating but it is not work correctly.
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
The code shown in this tutorial is just a sample. For a complete functional Alarm clock, much further enhancement in the code of the App may be needed. However, to simply enable daily alarm, try to repeat the below timer every 24 hours. t.scheduleAtFixedRate(new TimerTask() So, just encapsulating it with another similar scheduleAtFixedRate method with 24 hours period should help. Hope the above helps. For reference, complete source code shown in this tutorial is shared in the below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co -
3 жыл бұрын
@@ProgrammerWorld thank you very much, have a nice day
@hotwuk212
@hotwuk212 Жыл бұрын
it annoys me how complicated this is yet its like a first language to you or the people that develop
@chtpx9325
@chtpx9325 4 жыл бұрын
what if phone get locked the app will pause.. we will miss the alarm!, what about using pending intent
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
In this tutorial, the objective was to show the development of a very simple Alarm clock. If you are interested to run the App in background, the please refer to my below videos on this topic: kzfaq.info/get/bejne/g7idabGYv9LRdJc.html kzfaq.info/get/bejne/rt5zZ5BzsbS3g5c.html Hope the above helps. Good Luck Programmer World programmerworld.co
@mauriciogreboge
@mauriciogreboge 5 жыл бұрын
is it working with the phone blocked?
@albertosaucedo3594
@albertosaucedo3594 5 жыл бұрын
@@RabbilHasanRupom how to? I need learn that, can you help us? please give us hints
@minsaachohan1758
@minsaachohan1758 5 жыл бұрын
Sir my Android studio bot given option date and time picker ??
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Hi Minsaa, That's because google has removed the Date Time option from the palette of Android Studio from version 3.1. It was there in 3.0. The workaround is to manually add the time picker and time clock code in the XML format (text file). I given the code in the previous comments as a reply to Affael around 2 months ago. See the previous comments.
@minsaachohan1758
@minsaachohan1758 5 жыл бұрын
@@ProgrammerWorld thanku sir ..
@gordallackyan2454
@gordallackyan2454 5 жыл бұрын
I did so and got NullPointerException here if (currentTime.getText().toString().equals(AlarmTime())) My timer is null
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Hmm ... that’s odd. I assume your code is compiling correctly. And in that case there should not be any issues as all the objects would be created in the compiled code. Would it be possible to share your complete code, so that I can have a look?
@gordallackyan2454
@gordallackyan2454 5 жыл бұрын
package com.example.igor.myallarm; import android.annotation.SuppressLint; import android.media.Ringtone; import android.media.RingtoneManager; import android.os.Build; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.TextClock; import android.widget.TimePicker; import android.widget.Toast; import java.util.Timer; import java.util.TimerTask; public class MainActivity extends AppCompatActivity { TimePicker alarmTime; TextClock currentTime; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); alarmTime = findViewById(R.id.picker); currentTime = findViewById(R.id.clock); final Ringtone ringtone = RingtoneManager.getRingtone(getApplicationContext(), RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)); Timer t = new Timer(); t.scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (currentTime.getText().toString().equals(AlarmTime())) { ringtone.play(); } else { ringtone.stop(); } new Thread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "Sorry! Something went wrong", Toast.LENGTH_SHORT).show(); } }); } }, 0, 1000); } private String AlarmTime() { Integer alarmHour = alarmTime.getCurrentHour(); Integer alarmMinute = alarmTime.getCurrentMinute(); String stringAlarmMinutes; if (alarmMinute > 10) { stringAlarmMinutes = "0"; stringAlarmMinutes = stringAlarmMinutes.concat(alarmMinute.toString()); } else { stringAlarmMinutes = alarmMinute.toString(); } String stringAlarmTime; if (alarmHour > 12) { alarmHour = alarmHour - 12; stringAlarmTime = alarmHour.toString().concat(":").concat(stringAlarmMinutes).concat(" PM"); } else { stringAlarmTime = alarmHour.toString().concat(":").concat(stringAlarmMinutes).concat(" AM"); } return stringAlarmTime; } }
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Hi, Thanks for sharing your code. I went through your code. In first glance nothing looks unusual. However, I can see that in the AlarmTime() method, at line 61, you have used incorrect comparison sign in the IF statement. Instead of: if (alarmMinute > 10) please use: if (alarmMinute < 10) This comparison is done in the code because for the time below 10 minutes, the alarm time returns the minute value in single digit. So, to make it double digit (to be consistent with current time format), we concatenate the time for below 10 minutes with an extra 0. In your case since you have used the greater sign '>' in the IF comparison. Hence, it is concatenating an extra 0 for all the time greater than 10 minutes. Hence, making the minutes a 3 digit string. Which is not a supported format of time. Though I am not sure if this reason behind your nullpointer exception but this definitely needs corrected. Can you please do the above correction and let me know if it solved your problem? Else I will debug your code and try to figure out the reason for the failure. Right now I have not debugged your code as I will have to set your complete environment matching your class and object names. Please let me know if above does not solve your issue. Thanks Programmer World!
@gordallackyan2454
@gordallackyan2454 5 жыл бұрын
Der friend Thank you for notice that small mistake with ">". I have changed but it didn't help, I got NullPointerException again Then I used try catch block and got this @Override public void run() { try { if (currentTime.getText().toString().equals(AlarmTime())) { ringtone.play(); } else { ringtone.stop(); } } catch (NullPointerException e) { new Thread(new Runnable() { @Override public void run() { Toast.makeText(MainActivity.this, "Sorry! Something went wrong", Toast.LENGTH_SHORT).show(); } }); } } When I run the application doesn't crash and I got no exceptions, but the Alarm doesn't work, I set time, wait until equals to current time in mobile and nothing happens Thanks Programmer World!
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Hi Gor,, I created the environment and tested your code. On my machine it works perfectly fine. There is no exception thrown. I copied your code in my java file. The only modification I did was to change to '
@jeremytitus6575
@jeremytitus6575 3 жыл бұрын
Not able to make the code snippet for "timepicker" work >.
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
Are you getting any specific issues or error? Please note, timepicker is no more available in the palette of Android Layout designer. So, you may have to add manually in your XML code of your layout. Snippet below: Above snippet can be found in the link below: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Good Luck Programmer World programmerworld.co -
@vidhipunjabi3637
@vidhipunjabi3637 3 жыл бұрын
@@ProgrammerWorld Thank you for the information.
@keithrichards-fr1yr
@keithrichards-fr1yr Жыл бұрын
Make an Android app that triggers an alarm within a time slot everytime. Unique alarms each day.
@ninjanishigata7006
@ninjanishigata7006 4 жыл бұрын
Where is the......I can NOT find this clock palette. Maybe it's removed.
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Yes, it seems like time picker has been removed from the palette in Android Studio. As a workaround, you may have to add it manually in the Layout's XML file as below: You can also refer to the below link for complete code on the same: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co -
@mr.RAND5584
@mr.RAND5584 2 жыл бұрын
I want the alarm clock that say something. Can we use text to speech?
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
Yes, text to speech will be the best option. You can refer to my below page which shows how to implement a text to speech method in your Android App. programmerworld.co/android/how-to-convert-text-to-speech-in-your-android-app-complete-source-code/ Cheers Programmer World programmerworld.co -
@barath8190
@barath8190 Жыл бұрын
There is no sound bro what might be the problem
@meenuvarma9491
@meenuvarma9491 2 жыл бұрын
Which type of clock is this
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
This is a simple alarm clock which plays the ringtone as alarm when the current time reaches the alarm set time in the App. For reference, the complete source code shown in this video is also shared in the below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co -
@muhammadtalmeez3276
@muhammadtalmeez3276 5 жыл бұрын
everything is ok. No error occurred. but ringtone is not played. WHY?????
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Check if you have provided access to ring tones to your app. You can check that in Apps permission under settings. Other check is for the volume of the alarm voice. If everything looks ok then last option will be to debug the code and check. You can first try to debug the code using the emulator which may be easier to do than debugging it directly on the smartphone.
@ramkishorsoni8041
@ramkishorsoni8041 5 жыл бұрын
Same problem
@chocobarrel
@chocobarrel 5 жыл бұрын
@@ProgrammerWorld how to provide access to ring tones, provide code ?
@Affael
@Affael 6 жыл бұрын
time picker is gone from palette
@ProgrammerWorld
@ProgrammerWorld 6 жыл бұрын
Oh ... yes. Wow. So, it seems like google has removed the Date Time option from the palette of Android Studio from version 3.1. It was there in 3.0. Anyway, this issue has been discussed on other forums as well. The only workaround which I can think of is to manually add the time picker and time clock code in the XML format (text file). I am copying the snippet below which can be used in the layout XML file:
@prathameshjadhav5212
@prathameshjadhav5212 4 жыл бұрын
Time piker is not available?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
Yes, time picker has been removed from the Pallete in Android Studio. As a workaround, there are 2 options. 1. Either you add the timepicker widget using the test in XML file. Sample of the XML file is available on my below webpage: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ 2. Else you design your own timepicker layout in the resource folder and then use that in your main layout. Good Luck Programmer World programmerworld.co -
@engmajed5573
@engmajed5573 5 жыл бұрын
thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u thank u
@FAHADGAMING410
@FAHADGAMING410 Жыл бұрын
What is language using for this application?? Tell me anyone
@ProgrammerWorld
@ProgrammerWorld Жыл бұрын
This application is developed using Java language in Android Studio environment. For reference, details shown in this video is also shared in the below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co -
@abbasadrali
@abbasadrali 4 жыл бұрын
will it work if you kill the application
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
No, if you kill the App it may not work. For that you should watch my below video. In this video it is shown how to run Alarm clock in foreground service. So, in that case even if you kill the App, it will work. kzfaq.info/get/bejne/g7idabGYv9LRdJc.html
@mr.RAND5584
@mr.RAND5584 2 жыл бұрын
an alarm clock that open a youtube video. Coz i want an alarm clock that say hey take a break.
@jerfesoncampos8376
@jerfesoncampos8376 3 жыл бұрын
Ola nao conseguir fazer funcionar
@ProgrammerWorld
@ProgrammerWorld 3 жыл бұрын
What is the error you are getting? Cheers Programmer World programmerworld.co -
@AM-mk5sq
@AM-mk5sq 4 жыл бұрын
Waaait what you are using Windows 98?
@ProgrammerWorld
@ProgrammerWorld 4 жыл бұрын
No, I don't think this is Windows 98. I am surprised, what lead you to think so?
@r4rock511
@r4rock511 5 жыл бұрын
are you here
@ProgrammerWorld
@ProgrammerWorld 5 жыл бұрын
Yes
@Whiteroca
@Whiteroca 2 жыл бұрын
Does not work in Android Studio 2021.1
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
Could you please share some more details? Any specific error or widget is giving issue? For reference, the complete source code shown in this video is also shared in the below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co -
@palashprosenjitmalakar5450
@palashprosenjitmalakar5450 3 жыл бұрын
Your are not fluent in English and you should increase the font size at the time of video recording . Otherwise video is nice.
@bilgipaylasmplatformu8454
@bilgipaylasmplatformu8454 3 жыл бұрын
the alarm does'nt sound when the app is closed any fix for this?
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
Because this is the implementation of a normal Alarm App which runs only when App is active. If you want to run the App in background also (when App is closed) then please use the below concept: programmerworld.co/android/how-to-create-background-process-in-your-android-app/ Cheers Programmer World programmerworld.co/ -
@adenircamargo713
@adenircamargo713 3 жыл бұрын
Could have put the code in a normal style like every other person.
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
All the recent tutorials are in the code widget and soon the older pages are also being converted into code widget. So, it will be more readable. For reference the complete source code shown in this video is available in the below link: programmerworld.co/android/create-a-simple-alarm-clock-app-in-android-studio/ Cheers Programmer World programmerworld.co/ -
@averagebankaiuser5082
@averagebankaiuser5082 5 жыл бұрын
am i the only one that laughed at the 9/11?
@sergevinogradoff6024
@sergevinogradoff6024 2 жыл бұрын
OMG dude. Say 1 word per second, not 20. And upgrade you Windows XP.
@MycoDan
@MycoDan 5 жыл бұрын
Of course shitty android removed the widgets to build an alarm clock
@bernd32
@bernd32 4 жыл бұрын
Can you speak a proper English please? I don't understand Indian.
@cocoshort6528
@cocoshort6528 4 жыл бұрын
are you dumb lol
@EagleEye404
@EagleEye404 2 жыл бұрын
This is not a proper way to make alarm app or alarm. This is using timertask which is only alive when the app is foreground. This is misleading to beginner developer.
@ProgrammerWorld
@ProgrammerWorld 2 жыл бұрын
You are right, for a more effective alarm clock one should use background process approach which is explained in the below link: programmerworld.co/android/how-to-create-background-process-in-your-android-app/ Cheers Programmer World programmerworld.co -
AlarmManager в Android | XML | Android Studio & Kotlin
34:38
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 247 М.
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 55 МЛН
Finger Heart - Fancy Refill (Inside Out Animation)
00:30
FASH
Рет қаралды 29 МЛН
Best KFC Homemade For My Son #cooking #shorts
00:58
BANKII
Рет қаралды 72 МЛН
Learn Web Design For Beginners - Full Course (2024)
3:07:31
Flux Academy
Рет қаралды 1,7 МЛН
Java in 100 Seconds
2:25
Fireship
Рет қаралды 1,3 МЛН
How to design a simple Audio Recorder App in Android Studio?
22:52
Programmer World
Рет қаралды 12 М.
THIS Is How You Schedule Alarms on Android with AlarmManager
21:55
Philipp Lackner
Рет қаралды 37 М.
Android Scheduled Task Example using AlarmManager
18:14
Simplified Coding
Рет қаралды 83 М.
#3 Display Android notification at a particular time with Alarm Manager
5:59
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 55 МЛН