开发者

How to create Recurring of Alarm in Android

开发者 https://www.devze.com 2023-03-16 17:41 出处:网络
I am new to android.I am mak开发者_开发问答ing 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 c

I am new to android.I am mak开发者_开发问答ing 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

0

精彩评论

暂无评论...
验证码 换一张
取 消