From c01900846b8a3f7b2dec3a1b8d710b74eea57b07 Mon Sep 17 00:00:00 2001 From: LZ <2929718516@qq.com> Date: Wed, 25 Dec 2024 19:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E4=B8=AAAlarmReceiver=E7=B1=BB?= =?UTF-8?q?=E6=98=AF=E4=B8=80=E4=B8=AA=E5=B9=BF=E6=92=AD=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=8E=A5=E6=94=B6=E5=B9=BF?= =?UTF-8?q?=E6=92=AD=E6=B6=88=E6=81=AF=E3=80=82=E5=BD=93=E6=8E=A5=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E5=B9=BF=E6=92=AD=E6=97=B6=EF=BC=8C=E5=AE=83=E4=BC=9A?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E4=B8=80=E4=B8=AA=E6=96=B0=E7=9A=84Activity?= =?UTF-8?q?=EF=BC=88AlarmAlertActivity=EF=BC=89=EF=BC=8C=E4=BD=9C=E4=B8=BA?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=96=B0=E7=9A=84=E4=BB=BB=E5=8A=A1=E3=80=82?= =?UTF-8?q?=E8=BF=99=E9=80=9A=E5=B8=B8=E7=94=A8=E4=BA=8E=E5=9C=A8=E7=89=B9?= =?UTF-8?q?=E5=AE=9A=E4=BA=8B=E4=BB=B6=EF=BC=88=E5=A6=82=E9=97=B9=E9=92=9F?= =?UTF-8?q?=E5=93=8D=E8=B5=B7=EF=BC=89=E5=8F=91=E7=94=9F=E6=97=B6=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=94=A8=E6=88=B7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AlarmReceiver.java | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 AlarmReceiver.java diff --git a/AlarmReceiver.java b/AlarmReceiver.java new file mode 100644 index 0000000..8170be3 --- /dev/null +++ b/AlarmReceiver.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) + * 版权信息,指出这段代码由MiCode开源社区在2010-2011年间创作。 + */ + +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * 这段代码遵循Apache License 2.0版本授权。 + */ + +/* + * you may not use this file except in compliance with the License. + * 你只能遵守这个License来使用这个文件。 + */ + +/* + * You may obtain a copy of the License at + * 你可以在以下地址获取这个License的副本: + */ + + http://www.apache.org/licenses/LICENSE-2.0 + +/* + * Unless required by applicable law or agreed to in writing, software + * 除非遵循相关法律或者书面同意,否则 + */ + +/* + * distributed under the License is distributed on an "AS IS" BASIS, + * 在这个License下发布的软件是在“现状”基础上发布的, + */ + +/* + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 不附带任何形式的明示或暗示的担保或条件。 + */ + +/* + * See the License for the specific language governing permissions and + * 请查看这个License以了解关于权限和 + */ + +/* + * limitations under the License. + * 这个License下的限制条件。 + */ + +package net.micode.notes.ui; +// 声明这个类所在的包名。 + +import android.content.BroadcastReceiver; +// 导入Android的BroadcastReceiver类,用于接收广播消息。 + +import android.content.Context; +// 导入Android的Context类,表示应用环境的信息。 + +import android.content.Intent; +// 导入Android的Intent类,用于不同组件之间的通信。 + +public class AlarmReceiver extends BroadcastReceiver { +// 声明一个名为AlarmReceiver的类,它继承自BroadcastReceiver。 + + @Override + public void onReceive(Context context, Intent intent) { + // 重写onReceive方法,当接收到广播时调用,接收两个参数:Context和Intent。 + intent.setClass(context, AlarmAlertActivity.class); + // 设置Intent的目标Activity为AlarmAlertActivity。 + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + // 为Intent添加标志,表示这个Activity将作为一个新的任务启动。 + context.startActivity(intent); + // 使用Context启动Intent指定的Activity。 + } +} + \ No newline at end of file