Update AlarmReceiver.java

main
pf45q8f3g 7 months ago
parent e74509c1ce
commit 0f1110a443

@ -1,17 +1,15 @@
/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
* (c) 2010-2011, MiCode (www.micode.net)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* 使 Apache License, Version 2.0
* 使
*
*
* 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,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*
*/
// 指定类所在的包名
@ -22,22 +20,28 @@ import android.content.BroadcastReceiver; // 广播接收器基类
import android.content.Context; // 提供应用环境信息的类
import android.content.Intent; // 用于组件间通信的消息传递对象
// 定义一个公开类AlarmReceiver它继承自BroadcastReceiver
/**
* AlarmReceiver 广
* AlarmAlertActivity
*/
public class AlarmReceiver extends BroadcastReceiver {
// 重写onReceive方法当接收到广播时调用此方法
/**
* 广
* AlarmAlertActivity
*
* @param context
* @param intent 广 Intent
*/
@Override
public void onReceive(Context context, Intent intent) {
// 设置intent的目标组件为AlarmAlertActivity类
// 这意味着当这个广播接收器接收到广播时它希望启动AlarmAlertActivity活动
// 设置 intent 的目标组件为 AlarmAlertActivity
intent.setClass(context, AlarmAlertActivity.class);
// 为intent添加FLAG_ACTIVITY_NEW_TASK标志
// 这通常用于从非活动上下文中启动活动时,确保活动作为新的任务启动
// 添加 FLAG_ACTIVITY_NEW_TASK 标志,确保活动作为新的任务启动
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 使用context对象调用startActivity方法来启动由intent指定的活动
// 由于intent已经被设置为启动AlarmAlertActivity这行代码的作用就是启动AlarmAlertActivity活动
// 启动 AlarmAlertActivity 活动
context.startActivity(intent);
}
}
Loading…
Cancel
Save