简体   繁体   中英

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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM