Signed-off-by: rtc <rtc@qq.com>

pull/34/head
rtc 2 years ago
parent 5092d1458c
commit b7dfe3a9fb

@ -117,42 +117,38 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
try {
mPlayer.setDataSource(this, url); // 设置媒体放器的数据源为闹钟铃声的URI
mPlayer.prepare();
mPlayer.setLooping(true);
mPlayer.start();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
mPlayer.prepare(); // 准备异步播放
mPlayer.setLooping(true); // 设置循环播放
mPlayer.start(); // 开始播放
} catch (IllegalArgumentException e) { // 处理参数异常
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
} catch (SecurityException e) { // 处理安全异常
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
} catch (IllegalStateException e) { // 处理状态异常
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
} catch (IOException e) { // 处理IO异常
e.printStackTrace();
}
}
private void showActionDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.app_name);
dialog.setMessage(mSnippet);
dialog.setPositiveButton(R.string.notealert_ok, this);
if (isScreenOn()) {
dialog.setNegativeButton(R.string.notealert_enter, this);
dialog.setTitle(R.string.app_name); // 设置对话框标题
dialog.setMessage(mSnippet); // 设置对话框消息内容
dialog.setPositiveButton(R.string.notealert_ok, this); // 设置对话框的确定按钮和点击事件
if (isScreenOn()) { // 判断屏幕是否亮屏
dialog.setNegativeButton(R.string.notealert_enter, this); // 设置对话框的取消按钮和点击事件
}
dialog.show().setOnDismissListener(this);
dialog.show().setOnDismissListener(this); // 显示对话框,并设置对话框消失时的监听器
}
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case DialogInterface.BUTTON_NEGATIVE:
Intent intent = new Intent(this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(Intent.EXTRA_UID, mNoteId);
startActivity(intent);
Intent intent = new Intent(this, NoteEditActivity.class); // 创建一个Intent对象跳转到NoteEditActivity
intent.setAction(Intent.ACTION_VIEW); // 设置Intent的操作为查看操作
intent.putExtra(Intent.EXTRA_UID, mNoteId); // 设置Intent的额外数据
startActivity(intent); // 启动Activity
break;
default:
break;
@ -160,15 +156,14 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
public void onDismiss(DialogInterface dialog) {
stopAlarmSound();
finish();
stopAlarmSound(); // 停止播放铃声
finish(); // 结束当前Activity
}
private void stopAlarmSound() {
if (mPlayer != null) {
mPlayer.stop();
mPlayer.release();
mPlayer = null;
mPlayer.stop(); // 停止播放
mPlayer.release(); // 释放资源
mPlayer = null; // 置空
}
}
}

Loading…
Cancel
Save