收藏 分销(赏)

AndroidAlarm学习笔记.doc

上传人:仙人****88 文档编号:8617847 上传时间:2025-02-22 格式:DOC 页数:2 大小:14.97KB 下载积分:10 金币
下载 相关 举报
AndroidAlarm学习笔记.doc_第1页
第1页 / 共2页
AndroidAlarm学习笔记.doc_第2页
第2页 / 共2页
本文档共2页,全文阅读请下载到手机保存,查看更方便
资源描述
设置一个Alarm需要更新一下数据。 1. update alarms.db 2. update com.android.alarmclock_preferences.xml 3. update Settings.System.NEXT_ALARM_FORMATTED for status bar 4. set Kernel RTC alarm or send a message if no driver 具体的函数调用如下所示: com.android.alarmclock.AlarmClock.onCreate() -> SetAlarm.onPreferenceTreeClick() -> SetAlarm.saveAlarm() -> Alarm.setAlarm() -> Alarm.setNextAlert() -> Alarm.enableAlert(ALARM_ALERT_ACTION)/saveNextAlarm(Settings.System.NEXT_ALARM_FORMATTED) -> android.app.AlarmManager.set() -> AlarmManagerService.set() -> AlarmManagerService.setRepeating -> AlarmManagerService.setLocked() -> android.app.IAlarmManager.set() -> RTC.save()// /dev/alarms Alarm闹铃的函数调用如下所示: RTC (WAKEUP) -> AlarmReceiver.onReceive(ALARM_ALERT_ACTION) -> AlarmAlert.onCreate() -> AlarmAlertWakeLock.acquire()/KeyguardManager.newKeyguardLock().disableKeyguard() -> AlarmKlaxon.postPlay() ->  AlarmKlaxon.KillerCallback().onKilled() -> AlarmAlert.dismiss() -> AlarmAlertWakeLock.release()/KeyguardManager.newKeyguardLock().reenableKeyguard() DeskClock App中的code block说明如下: Alarm是描述闹钟的抽象类。 AlarmAlert处理闹铃过程中系统相关的事件,继承AlarmAlertFullScreen。 AlarmAlertFullScreen显示闹铃界面,并处理闹钟界面上到控件消息。 AlarmAlertWakeLock提供控制wakelock接口。 AlarmClock闹钟界面,包括闹钟列表、数字时钟、option菜单。 AlarmKlaxon是一个服务,提供闹铃和震动功能,如果一个闹铃fire,前面一个闹铃已经在闹来,则取消前面那个,闹后来者。 AlarmPreference闹铃文件。 ContentProvider维护闹钟表,字段包括_id、hour、minutes、daysofweek、alarmtime、enabled、vibrate、message、alert。 Alarms提供了操作闹钟的接口,相当于AlarmManager。enableAlert()设置一个闹钟,用的是PendingIntent到方式计算时间。RTC的设置在enableAlert()的am.set(AlarmManager.RTC_WAKEUP, atTimeInMillis, sender); RTC_WAKEUP表示该Alarm如果在关机的情况下来到,则会自动开机闹铃。 DeskClock桌面时钟到activity。其中包括了系统时间、日期、电池及天气等信息,其中天气信息是判断是否存在提供天气信息的app后,从数据库中读取当前的天气信息来更新。也就是天气APP只需要更新数据库中的天气信息即可。 DigitalClock维护数字时钟。 HandleSetAlarm设置alarm到activity。 Framework相关的code block如下: AlarmManager和AlarmManagerService,这两个文件组成了AlarmService。 关于PendingIntent: PendingIntent就是一个Intent的描述,我们可以把这个描述交给别的程序,别的程序根据这个描述在后面的别的时间做你安排做的事情 (By giving a PendingIntent to another application, you are granting it the right to perform the operation you have specified as if the other application was yourself,就相当于PendingIntent代表了Intent)。本例中别的程序就是发送短信的程序,短信发送成功后要把intent广播出去。
展开阅读全文

开通  VIP会员、SVIP会员  优惠大
下载10份以上建议开通VIP会员
下载20份以上建议开通SVIP会员


开通VIP      成为共赢上传

当前位置:首页 > 教育专区 > 小学其他

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服