重复闹钟每天在特定的时间(报警经理) [英] Repeat alarm everyday at specific time (Alarm manager)

查看:150
本文介绍了重复闹钟每天在特定的时间(报警经理)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我想我的应用程序在特定的时间每​​天运行。为此我使用低于code。但它只是一个时间运行。请告诉我错在这里,我怎么能实现这个任务。

Hi I want my application to run at specific time daily. for this I am using below code. But it runs only for one time. Whats the mistake here how can i achieve this task.

AlarmManager alarmMgr0 = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
Intent intent0 = new Intent(this, ActivityStarter.class);
PendingIntent pendingIntent0 = PendingIntent.getBroadcast(this, 0, intent0, 0);
Calendar timeOff9 = Calendar.getInstance();
timeOff9.set(Calendar.HOUR_OF_DAY, 16);
timeOff9.set(Calendar.MINUTE, 13);
timeOff9.set(Calendar.SECOND, 0);
alarmMgr0.setRepeating(AlarmManager.RTC_WAKEUP, timeOff9.getTimeInMillis(),24*60*60*1000,pendingIntent0);

任何帮助,请。

推荐答案

试试这个

 alarmMgr0 .setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
        SystemClock.elapsedRealtime() + AlarmManager.INTERVAL_DAY,
        AlarmManager.INTERVAL_DAY, intent);

这篇关于重复闹钟每天在特定的时间(报警经理)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆