|
|
|
|
@ -14,17 +14,34 @@
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// 包声明,表明该类属于 net.micode.notes.ui 包
|
|
|
|
|
package net.micode.notes.ui;
|
|
|
|
|
|
|
|
|
|
// 导入 Android 广播接收器相关类
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
|
// 导入 Android 上下文相关类
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
// 导入 Android 意图相关类
|
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* AlarmReceiver 类用于接收系统广播,并在接收到广播时启动 AlarmAlertActivity。
|
|
|
|
|
* 它继承自 BroadcastReceiver,用于处理特定的广播事件。
|
|
|
|
|
*/
|
|
|
|
|
public class AlarmReceiver extends BroadcastReceiver {
|
|
|
|
|
/**
|
|
|
|
|
* 当接收到广播时,此方法会被调用。
|
|
|
|
|
*
|
|
|
|
|
* @param context 上下文对象,提供对应用环境的访问
|
|
|
|
|
* @param intent 接收到的广播意图,包含广播的相关信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
// 设置意图的目标类为 AlarmAlertActivity,即当接收到广播时要启动的活动类
|
|
|
|
|
intent.setClass(context, AlarmAlertActivity.class);
|
|
|
|
|
// 为意图添加 FLAG_ACTIVITY_NEW_TASK 标志,以便在新的任务栈中启动活动
|
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
|
// 使用上下文对象启动活动,根据前面设置的意图启动 AlarmAlertActivity
|
|
|
|
|
context.startActivity(intent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|