Android原生模块DeskClock分析1(3)
//当系统进入睡眠状态时,这种类型的闹铃不会唤醒系统。直到系统下次被唤醒才传递它,该闹铃所用的时间是绝对时间,所用时间是UTC时间,可以通过调用 System.currentTimeMillis()获得。系统值是1 (0x00000001) 。
public static final int RTC_WAKEUP
//能唤醒系统,用法同RTC类型,系统值为 0 (0x00000000) 。
Public static final int POWER_OFF_WAKEUP
8
DeskClock分析文档
//能唤醒系统,它是一种关机闹铃,就是说设备在关机状态下也可以唤醒系统,所以我们把它称之为关机闹铃。使用方法同RTC类型,系统值为4(0x00000004)。
? AlarmKlaxon通过继承Service,来实现功能,他在后台运行。
? 闹铃模式:Vibrator(震动)VIBRATOR_SERVICE,TelephonyManager(响铃)
TELEPHONY_SERVICE private void play(Alarm alarm) {
// stop() checks to see if we are already playing. stop();
if (Log.LOGV) {
Log.v(\ }
if (!alarm.silent) {Log.e(\ Uri alert = alarm.alert;
// Fall back on the default alarm if the database does not have an // alarm stored.
if (alert == null) {Log.e(\ alert = RingtoneManager.getDefaultUri( RingtoneManager.TYPE_ALARM); if (Log.LOGV) {Log.e(\
Log.v(\ } }
// TODO: Reuse mMediaPlayer instead of creating a new one and/or use // RingtoneManager.
mMediaPlayer = new MediaPlayer();
mMediaPlayer.setOnErrorListener(new OnErrorListener() { public boolean onError(MediaPlayer mp, int what, int extra) { Log.e(\ mp.stop(); mp.release(); mMediaPlayer = null; Log.e(\ return true; } });
try {
// Check if we are in a call. If we are, use the in-call alarm // resource at a low volume to not disrupt the call.
9
DeskClock分析文档
if (mTelephonyManager.getCallState()
!= TelephonyManager.CALL_STATE_IDLE) {Log.e(\ Log.v(\
mMediaPlayer.setVolume(IN_CALL_VOLUME, IN_CALL_VOLUME); setDataSourceFromResource(getResources(), mMediaPlayer, R.raw.in_call_alarm); } else {Log.e(\
mMediaPlayer.setDataSource(this, alert); }
startAlarm(mMediaPlayer); } catch (Exception ex) {
Log.v(\
// The alert may be on the sd card which could be busy right // now. Use the fallback ringtone. try {
// Must reset the media player to clear the error state. mMediaPlayer.reset();
setDataSourceFromResource(getResources(), mMediaPlayer, R.raw.fallbackring); startAlarm(mMediaPlayer); } catch (Exception ex2) {
// At this point we just don't play anything. Log.e(\ } } }
/* Start the vibrator after everything is ok with the media player */ if (alarm.vibrate) {Log.e(\ mVibrator.vibrate(sVibratePattern, 0); } else {Log.e(\ mVibrator.cancel(); }
enableKiller(alarm); mPlaying = true;
mStartTime = System.currentTimeMillis();
}
? AlarmClock继承Activity实现OnItemClickListener接口
· AlarmClock是一个Activity类,主要功能是将闹钟界面显示出来,并通过各种组件控件,
实现人机交互功能,其中包括listView,adapter,menu,cursor等组件。
· 这里定义一个AlarmTimeAdapter继承CursorAdapter,用来显示闹钟列表的适配器。这里
10
…… 此处隐藏:522字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [实用模板]第八章:法国“新浪潮”与“左岸派”
- [实用模板]2021年北京上半年临床医学检验技师生物
- [实用模板]SAP GUI 7.10客户端安装配置文档
- [实用模板]2001年临床执业医师资格考试综合笔试试
- [实用模板]36机场工作实用英语词汇总结
- [实用模板](一)社会保险稽核通知书
- [实用模板]安全教育主题班会材料
- [实用模板]濉溪县春季呼吸道传染病防控应急演练方
- [实用模板]长沙房地产市场周报(1.30-2.3)
- [实用模板]六年级数学上册典中点 - 图文
- [实用模板]C程序设计(红皮书)习题官方参考答案
- [实用模板]中国证监会第一届创业板发行审核委员会
- [实用模板]桥梁工程复习题
- [实用模板]2011学而思数学及答案
- [实用模板]初中病句修改专项练习
- [实用模板]监理学习知识1 - 图文
- [实用模板]小机灵杯四年级试题
- [实用模板]国贸专业毕业论文模板
- [实用模板]教育学概论考试练习题-判断题4
- [实用模板]2015届高考英语一轮复习精品资料(译林
- 00Nkmhe_市场营销学工商管理_电子商务_
- 事业单位考试法律常识
- 诚信教育实施方案
- 吉大小天鹅食品安全检测箱方案(高中低
- 房地产销售培训资料
- 高一地理必修1复习提纲
- 新概念英语第二册lesson_1_练习题
- 证券公司内部培训资料
- 小学英语时间介词专项练习
- 新世纪英语专业综合教程(第二版)第1册U
- 【新课标】浙教版最新2018年八年级数学
- 工程建设管理纲要
- 外研版 必修一Module 4 A Social Surve
- Adobe认证考试 AE复习资料
- 基于H.264AVC与AVS标准的帧内预测技术
- 《食品检验机构资质认定管理办法》(质
- ABB变频器培训课件
- (完整版)小学说明文阅读练习题及答案
- 深思洛克(SenseLock) 深思IV,深思4,深
- 弟子规全文带拼音




