首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android 闹钟机制兑现定时任务

2013-02-19 
Android 闹钟机制实现定时任务? ?? ?? ?? ?/intent-filter? ?? ???/receiver3. 重开机后重新计算并设

Android 闹钟机制实现定时任务
? ?? ?? ?? ?</intent-filter>
? ?? ???</receiver>

3. 重开机后重新计算并设置闹铃时间
当然要有一个BootReceiver:
public class BootReceiver extends BroadcastReceiver {
? ? public void onReceive(Context context, Intent intent) {
? ?? ???String action = intent.getAction();
? ?? ???if (action.equals(Intent.ACTION_BOOT_COMPLETED)) {
? ?? ?? ?? ?//重新计算闹铃时间,并调第一步的方法设置闹铃时间及闹铃间隔时间
? ?? ???}
? ? }
}
当然,也需要注册:
? ?? ???<receiver android:name="BootReceiver">
? ?? ?? ?? ?<intent-filter>
? ?? ?? ?? ?? ? <action android:name="android.intent.action.BOOT_COMPLETED" />
? ?? ?? ?? ?</intent-filter>
? ?? ???</receiver>


闹钟实现原理其实就这么多,至于具体的细节比如闹铃时间存储及计算,界面显示及闹铃提示方式,每个人的想法做法都会不一样,就不赘述

热点排行