这段代码是一个Android广播接收器(BroadcastReceiver),它的核心作用是在系统闹钟提醒触发时,启动一个全屏的提醒界面。

duan
dxj 2 months ago
parent a58728df00
commit d0a5d5ab38

@ -1,30 +1,39 @@
/* /*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) * MiCode
* * Apache License 2.0
* 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; package net.micode.notes.ui;
// 导入必要的Android类
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
/**
* BroadcastReceiver
* 广
*/
//111111111111111
// 11111111111
public class AlarmReceiver extends BroadcastReceiver { public class AlarmReceiver extends BroadcastReceiver {
/**
* 广
* @param context
* @param intent 广
*/
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
// 将接收到的意图重定向到闹钟提醒Activity
intent.setClass(context, AlarmAlertActivity.class); intent.setClass(context, AlarmAlertActivity.class);
// 添加新的任务栈标识因为可能从非Activity环境启动Activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
// 启动闹钟提醒界面Activity
context.startActivity(intent); context.startActivity(intent);
} }
} }
Loading…
Cancel
Save