|
|
/*
|
|
|
* 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);
|
|
|
}
|
|
|
} |