You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
/*
* 版权所有 (c) 2010-2011, MiCode 开源社区 (www.micode.net)
* 根据 Apache 许可证 2.0 版本("许可证")授权;
* 除非符合许可证的规定,否则不得使用本文件。
* 您可以从以下网址获取许可证副本:
* http://www.apache.org/licenses/LICENSE-2.0
* 除非适用法律要求或书面同意,本软件按"原样"分发,
* 没有任何明示或暗示的保证或条件。
* 详见许可证中规定的权限和限制。
* ( 注: 这是一份标准的Apache许可证2.0版本的开源声明)
*/
// 定义包路径,指明该类所在的包位置
package net.micode.notes.ui ;
// 导入Android相关类库
import android.annotation.SuppressLint ;
import android.content.BroadcastReceiver ; // 广播接收器基类
import android.content.Context ; // 上下文对象,提供应用环境信息
import android.content.Intent ; // 意图对象,用于组件间通信
/**
* 闹钟广播接收器
* 接收系统闹钟触发广播,启动闹钟提醒界面
* 功能说明:
* 1. 继承自BroadcastReceiver, 专门处理闹钟触发事件
* 2. 当闹钟触发时, 启动AlarmAlertActivity显示提醒
* 3. 作为系统闹钟和用户界面之间的桥梁
*/
public class AlarmReceiver extends BroadcastReceiver {
/**
* 广播接收回调方法
* 当闹钟触发时由系统自动调用
*
* @param context 上下文对象, 提供启动Activity所需的运行环境
* @param intent 包含触发闹钟的相关信息, 特别是笔记的URI数据
*/
@Override
public void onReceive ( Context context , @SuppressLint ( "UnsafeIntentLaunch" ) Intent intent ) {
// 修改Intent的目标组件为AlarmAlertActivity
intent . setClass ( context , AlarmAlertActivity . class ) ;
// 添加NEW_TASK标志, 因为从非Activity上下文启动Activity需要此标志
intent . addFlags ( Intent . FLAG_ACTIVITY_NEW_TASK ) ;
// 启动闹钟提醒Activity
context . startActivity ( intent ) ;
/// 注意点:
/// 1. 原Intent中已经包含了笔记URI数据( 在AlarmInitReceiver中设置)
/// 2. FLAG_ACTIVITY_NEW_TASK确保可以正确启动Activity
/// 3. 此方法执行时间应尽量短, 避免ANR( 应用无响应) 错误
}
}