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