Nitin
Nitin

Reputation: 1986

How to create Recurring of Alarm in Android

I am new to android.I am making an Application where I have to take user input more then once and set alarm more then once in a day So can you please tell me how can i achieve this? I can set alarm any time once a day So can you please tell what kind of logic what is the best way to achieve.

Upvotes: 0

Views: 1023

Answers (2)

Balaji.K
Balaji.K

Reputation: 4829

Intent intent1 = new Intent(this, give the sameclassname.class);
     PendingIntent pintent = PendingIntent.getService(this, 0, intent1, 0);
     AlarmManager alarm = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
     alarm.setRepeating(AlarmManager.RTC, System.currentTimeMillis()+timeinminutes*60*1000,30*1000,  pintent);

this code repeats the alarm based on the "timeinminutes". This is the variable.

Upvotes: 4

Mads Lee Jensen
Mads Lee Jensen

Reputation: 4648

Im not entirely sure i understand your question but you should take a look at the AlarmManager

Theres a couple of examples (under alarms)

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/index.html

and

http://developer.android.com/reference/android/app/AlarmManager.html

Upvotes: 0

Related Questions