Alarm.java
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class Alarm extends Activity {
TimePicker TimePicker;
Button Setalarm;
TimePickerDialog timePickerDialog;
final static int RQS_1 = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
Setalarm = (Button) findViewById(R.id.Setalarm);
Setalarm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openTimePickerDialog(false);
}
});
}
private void openTimePickerDialog(boolean is24r) {
Calendar calendar = Calendar.getInstance();
timePickerDialog = new TimePickerDialog(Alarm.this, onTimeSetListener,
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE), is24r);
timePickerDialog.setTitle("Set Alarm");
timePickerDialog.show();
}
OnTimeSetListener onTimeSetListener = new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Calendar calNow = Calendar.getInstance();
Calendar calSet = (Calendar) calNow.clone();
calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
calSet.set(Calendar.MINUTE, minute);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
if (calSet.compareTo(calNow) <= 0) {
calSet.add(Calendar.DATE, 1);
}
setAlarm(calSet);
}
};
private void setAlarm(Calendar targetCal) {
//
Toast.makeText(Alarm.this, "Alarm is set at" + targetCal.getTime(),
Toast.LENGTH_LONG).show();
Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
getBaseContext(), RQS_1, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),
pendingIntent);
}
}
AlarmReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Toast.makeText(arg0, "Your Time is up!!!!!", Toast.LENGTH_LONG).show();
}
}
activity_alarm.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Setalarm"
android:layout_width="117dp"
android:layout_height="106dp"
android:background="@drawable/alarm" />
<TextView
android:id="@+id/alarmprompt"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alarm_manager"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.alarm_manager.Alarm"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="AlarmReceiver"></receiver>
</application>
</manifest>
Screenshot
import java.util.Calendar;
import android.app.Activity;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.TimePickerDialog;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
public class Alarm extends Activity {
TimePicker TimePicker;
Button Setalarm;
TimePickerDialog timePickerDialog;
final static int RQS_1 = 1;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_alarm);
Setalarm = (Button) findViewById(R.id.Setalarm);
Setalarm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
openTimePickerDialog(false);
}
});
}
private void openTimePickerDialog(boolean is24r) {
Calendar calendar = Calendar.getInstance();
timePickerDialog = new TimePickerDialog(Alarm.this, onTimeSetListener,
calendar.get(Calendar.HOUR_OF_DAY),
calendar.get(Calendar.MINUTE), is24r);
timePickerDialog.setTitle("Set Alarm");
timePickerDialog.show();
}
OnTimeSetListener onTimeSetListener = new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
Calendar calNow = Calendar.getInstance();
Calendar calSet = (Calendar) calNow.clone();
calSet.set(Calendar.HOUR_OF_DAY, hourOfDay);
calSet.set(Calendar.MINUTE, minute);
calSet.set(Calendar.SECOND, 0);
calSet.set(Calendar.MILLISECOND, 0);
if (calSet.compareTo(calNow) <= 0) {
calSet.add(Calendar.DATE, 1);
}
setAlarm(calSet);
}
};
private void setAlarm(Calendar targetCal) {
//
Toast.makeText(Alarm.this, "Alarm is set at" + targetCal.getTime(),
Toast.LENGTH_LONG).show();
Intent intent = new Intent(getBaseContext(), AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(
getBaseContext(), RQS_1, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
alarmManager.set(AlarmManager.RTC_WAKEUP, targetCal.getTimeInMillis(),
pendingIntent);
}
}
AlarmReceiver.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
Toast.makeText(arg0, "Your Time is up!!!!!", Toast.LENGTH_LONG).show();
}
}
activity_alarm.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/Setalarm"
android:layout_width="117dp"
android:layout_height="106dp"
android:background="@drawable/alarm" />
<TextView
android:id="@+id/alarmprompt"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.alarm_manager"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.alarm_manager.Alarm"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name="AlarmReceiver"></receiver>
</application>
</manifest>
Screenshot
Alarm is not working when the app is closed. How to fix this please help.
ReplyDeleteThanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area.
ReplyDeleteDigital Marketing Training in Pune
Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article. thank you for sharing such a great blog with us.
ReplyDeleteClick here:
python training in Bangalore
Click here:
python training in Bangalore
Wonderful article, very useful and well explanation. Your post is extremely incredible. I will refer this to my candidates...
ReplyDeleteData Science training in marathahalli
Data Science training in btm
Data Science training in rajaji nagar
Data Science training in chennai
Data Science training in electronic city
Data Science training in USA
Data science training in pune
Data science training in kalyan nagar
Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
ReplyDeleteData Science with Python training in chenni
Data Science training in chennai
Data science training in velachery
Data science training in tambaram
Data Science training in anna nagar
Data Science training in chennai
Data science training in Bangalore
Wonderful article, very useful and well explanation. Your post is extremely incredible. I will refer this to my candidates...
ReplyDeletejava training in chennai | java training in USA
selenium training in chennai
Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
ReplyDeletepython training in chennai
python training in chennai
python training in Bangalore
Thanks you for sharing this unique useful information content with us. Really awesome work. keep on blogging
ReplyDeleteDevops training in sholinganallur
Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
ReplyDeletejava online training | java training in pune
java training in chennai | java training in bangalore
I recently came across your blog and have been reading along. I thought I would leave my first comment.
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
Very good brief and this post helped me alot. Say thank you I searching for your facts. Thanks for sharing with us!
ReplyDeleteangularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs online Training
angularjs Training in marathahalli
It would have been the happiest moment for you,I mean if we have been waiting for something to happen and when it happens we forgot all hardwork and wait for getting that happened.
ReplyDeleteangularjs Training in chennai
angularjs-Training in pune
angularjs-Training in chennai
angularjs Training in chennai
angularjs-Training in tambaram
Useful information.I am actual blessed to read this article.thanks for giving us this advantageous information.I acknowledge this post.and I would like bookmark this post.Thanks
ReplyDeleteangularjs Training in bangalore
angularjs Training in btm
angularjs Training in electronic-city
angularjs online Training
angularjs Training in marathahalli
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteSelenium Interview Questions and Answers
Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteSelenium Interview Questions and Answers
Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteSelenium Interview Questions and Answers
Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteSelenium Interview Questions and Answers
Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
Whoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteSelenium Interview Questions and Answers
Best Selenium Training in Chennai | Selenium Training Institute in Chennai | Besant Technologies
Selenium Training in Bangalore | Best Selenium Training in Bangalore
Best AWS Training in Marathahalli | AWS Training in Marathahalli
Amazon Web Services Training in Anna Nagar, Chennai |Best AWS Training in Anna Nagar, Chennai
Nice post. By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
ReplyDeletePython training in marathahalli | Python training institute in pune | Python training in IndiraNagar
Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.
ReplyDeleteAWS Training in Bangalore | Amazon Web Services Training in Bangalore
AWS Training in Bangalore |Best AWS Training Institute in BTM ,Marathahalli
AWS Training in Rajaji Nagar | Amazon Web Services Training in Rajaji Nagar
Best AWS Training Institute in BTM Layout Bangalore ,AWS Coursesin BTM
Best AWS Training in Marathahalli | AWS Training in Marathahalli
I have been meaning to write something like this on my website and you have given me an idea. Cheers.
ReplyDeleteMicrosoft Azure online training
Selenium online training
Java online training
Java Script online training
Share Point online training
Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries.
ReplyDeletedevops online training
aws online training
data science with python online training
data science online training
rpa online training
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteLinux Training in Chennai
Python Training in Chennai
Data Science Training in Chennai
RPA Training in Chennai
Devops Training in Chennai
ReplyDeleteThis is one of the best blog and I got more different ideas about this topic. Really happy to see your wonderful post and keep posting
Oracle Training in Chennai
Oracle Training institute in chennai
Pega Training in Chennai
Tableau Training in Chennai
Oracle DBA Training in Chennai
Primavera Training in Chennai
Unix Training in Chennai
Power BI Training in Chennai
Oracle Training in Chennai
Oracle Training institute in chennai
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeleteblue prism Training in Electronic City
Thank you so much for providing the valuable information
ReplyDeleteAngularJS Training in Chennai | AngularJS Training in Anna Nagar | AngularJS Training in OMR | AngularJS Training in Porur | AngularJS Training in Tambaram | AngularJS Training in Velachery
This is the best explanation about this topic, it is very useful and valuable content to all readers. I am always following your post, please updates more different posts.keep it up.
ReplyDeleteAi & Artificial Intelligence Course in Chennai
PHP Training in Chennai
Ethical Hacking Course in Chennai Blue Prism Training in Chennai
UiPath Training in Chennai
This comment has been removed by the author.
ReplyDeleteThis topic very useful to me!!!
ReplyDeleteAndroid Training in Chennai | Certification | Mobile App Development Training Online | Android Training in Bangalore | Certification | Mobile App Development Training Online | Android Training in Hyderabad | Certification | Mobile App Development Training Online | Android Training in Coimbatore | Certification | Mobile App Development Training Online | Android Training in Online | Certification | Mobile App Development Training Online
welcome to the next in a recent article. Read all the information given in above article. It'll give u the whole idea about it.
ReplyDeleteAngular js Training in Chennai
Angular js Training in Velachery
Angular js Training in Tambaram
Angular js Training in Porur
Angular js Training in Omr
Angular js Training in Annanagar
Thanks for an amazing post. this post is very interesting and informative. Loved reading it.
ReplyDeleteSelenium Training in Chennai
Selenium Training in Velachery
Selenium Training in Tambaram
Selenium Training in Porur
Selenium Training in Omr
Selenium Training in Annanagar
Wonderful article, very useful and well explanation. Your post is extremely incredible. I will refer this to my candidates...
ReplyDeleteamazon web services aws training in chennai
microsoft azure course in chennai
workday course in chennai
android course in chennai
ios course in chennai
Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.
ReplyDeletetally course in chennai
hadoop course in chennai
sap course in chennai
oracle course in chennai
angular js course in chennai
Really it was an awesome article,very interesting to read.You have provided an nice article,Thanks for sharing.a
ReplyDeleteJava training in chennai
python training in chennai
web designing and development training course in chennai
selenium training in chennai
digital-marketing seo training in chennai
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.
ReplyDeletesalesforce course in chennai
software testing course in chennai
robotic process automation rpa course in chennai
blockchain course in chennai
devops course in chennai
This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.
ReplyDeleteIELTS Coaching in chennai
German Classes in Chennai
GRE Coaching Classes in Chennai
TOEFL Coaching in Chennai
Spoken english classes in chennai | Communication training
Learn Big Data for the best career opportunities with Infycle Technologies. Infycle Technologies is the best Big Data training institute in Chennai, providing courses for the Big Data Training in Chennai in 100% hands-on practical training with expert trainers in the field. Apart from the training, the mock interviews will be arranged for the students, so that they can set their career without any struggle. Of all that, 100% placement assurance will be given here. For the best career, call 7502633633 to Infycle Technologies and grab a free demo to know more.
ReplyDeletetop big data training institute in Chennai
ReplyDeleteThis post is so interactive and informative.keep update more information...
Tally Course in Chennai
Tally Classes in Chennai
Online Tally Course
Infycle Technologies, the best software training institute in Chennai offers the Data Science Certification in Chennai for students, tech professionals, and freshers. Apart from the Data Science Course, other courses such as Python, Cyber Security, Oracle, Java, Hadoop, Selenium, Android, and iOS Development, Big Data will also be trained with 100% hands-on training. After the completion of training, the students will be sent for placement interviews in the core MNC's. Dial 7502633633 to get more info and a free demo.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGrab the Digital Marketing Training in Chennai from Infycle Technologies, the best software training institute, and Placement center in Chennai which is providing professional software courses such as Data Science, Artificial Intelligence, Cyber Security, Big Data, Java, Hadoop, Selenium, Android, and iOS Development, DevOps, Oracle etc with 100% hands-on practical training. Dial 7502633633 to get more info and a free demo and to grab the certification for having a peak rise in your career.
ReplyDelete