孙永霖_branch
syl 1 year ago
parent 46626096f5
commit 62f00cbff3

@ -56,7 +56,8 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); // 设置当前Activity的Window对象的属性使其在锁定状态时保持常亮
if (!isScreenOn()) { // 判断当前屏幕是否处于锁定状态
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON // 如果当前屏幕处于锁定状态则设置当前Activity的Window对象的属性使其在锁定状态时保持常亮并允许锁定屏幕
win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON // 如果当前屏幕处于锁定状态,
//则设置当前Activity的Window对象的属性使其在锁定状态时保持常亮并允许锁定屏幕
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
@ -77,7 +78,9 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
mPlayer = new MediaPlayer(); // 初始化mPlayer
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { // 判断mNoteId对应的Notes表中的TYPE_NOTE字段是否可见
// 判断mNoteId对应的Notes表中的TYPE_NOTE字段是否可见
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
showActionDialog(); // 如果可见则显示ActionDialog
playAlarmSound(); // 播放闹钟音效
} else {
@ -88,7 +91,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
private boolean isScreenOn() { // 判断当前屏幕是否处于锁定状态
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); // 获取当前系统的PowerManager实例
return pm.isScreenOn(); // 判断当前屏幕是否处于锁定状态
return pm.isScreenOn(); // 返回当前屏幕锁定状态
}
@ -104,6 +107,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
mPlayer.setAudioStreamType(AudioManager.STREAM_ALARM); // 如果不包含则设置mPlayer的音频流类型为AudioManager.STREAM_ALARM
}
try {
mPlayer.setDataSource(this, url); // 设置mPlayer的数据源
mPlayer.prepare(); // 准备播放
mPlayer.setLooping(true); // 设置mPlayer循环播放
@ -125,7 +129,9 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
private void showActionDialog() { // 显示ActionDialog
AlertDialog.Builder dialog = new AlertDialog.Builder(this); // 创建一个AlertDialog.Builder实例
dialog.setTitle(R.string.app_name); // 设置AlertDialog的标题
dialog.setMessage(mSnippet); // 设置AlertDialog的消息
dialog.setPositiveButton(R.string.notealert_ok, this); // 设置AlertDialog的确定按钮

@ -20,12 +20,13 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class AlarmReceiver extends BroadcastReceiver { // 创建一个AlarmReceiver类继承自BroadcastReceiver
// 创建一个AlarmReceiver类继承自BroadcastReceiver在接收到特定广播时启动 AlarmAlertActivity 活动。
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) { // 重写onReceive方法接收Intent类型的参数
intent.setClass(context, AlarmAlertActivity.class); // 设置AlarmAlertActivity的Class
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 设置AlarmAlertActivity的Flag
// 重写onReceive方法接收Intent类型的参数
public void onReceive(Context context, Intent intent) {
intent.setClass(context, AlarmAlertActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent); // 启动AlarmAlertActivity
}
}

@ -165,7 +165,7 @@ private NumberPicker.OnValueChangeListener mOnDateChangedListener = new NumberPi
};
public interface OnDateTimeChangedListener { // 添加中文注释后
public interface OnDateTimeChangedListener {
void onDateTimeChanged(DateTimePicker view, int year, int month, // 当时间改变时调用
int dayOfMonth, int hourOfDay, int minute);
@ -177,12 +177,12 @@ public interface OnDateTimeChangedListener { // 添加中文注释后
}
public DateTimePicker(Context context, long date) { // 创建一个DateTimePicker对象参数为context和datedateFormat默认为24小时制
public DateTimePicker(Context context, long date) { // 创建一个DateTimePicker对象参数为context和datedateFormat默认为24小时制
this(context, date, DateFormat.is24HourFormat(context));
}
public DateTimePicker(Context context, long date, boolean is24HourView) { // 创建DateTimePicker对象传入上下文、日期和是否24小时视图
public DateTimePicker(Context context, long date, boolean is24HourView) { // 创建DateTimePicker对象传入上下文、日期和是否24小时视图
super(context);
mDate = Calendar.getInstance();
mInitialising = true;

Loading…
Cancel
Save