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.
git.text/src/ui/AlarmReceiver.java

46 lines
1.9 KiB

This file contains ambiguous Unicode characters!

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.

/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (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
*
* 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.
*/
package net.micode.notes.ui;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
/**
* 便签提醒广播接收器,负责接收系统闹钟触发的广播,并启动提醒展示界面
* 是小米便签提醒流程中连接闹钟触发与提醒展示的中间组件
*/
public class AlarmReceiver extends BroadcastReceiver {
/**
* 接收广播时触发的回调方法
* @param context 上下文环境用于启动Activity
* @param intent 接收到的意图包含触发提醒的便签信息如便签ID
*/
@Override
public void onReceive(Context context, Intent intent) {
// 将意图的目标组件设置为AlarmAlertActivity便签提醒展示界面
// 确保广播中携带的便签信息如Data中的便签ID被传递给目标界面
intent.setClass(context, AlarmAlertActivity.class);
// 添加FLAG_ACTIVITY_NEW_TASK标志在BroadcastReceiver中启动Activity必须设置此标志
// 因为BroadcastReceiver本身没有任务栈需要为启动的Activity创建新任务栈
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 启动AlarmAlertActivity展示便签提醒对话框并播放铃声
context.startActivity(intent);
}
}