diff --git a/src/.idea/workspace.xml b/src/.idea/workspace.xml index e52b0b1..3e7b652 100644 --- a/src/.idea/workspace.xml +++ b/src/.idea/workspace.xml @@ -2,14 +2,15 @@ - + + zh-rTW + - - - + + - - - - - - - - - - - - - - - - - - - - + + - - - - - - - - - - - + + @@ -150,15 +124,15 @@ @@ -327,6 +301,17 @@ + + @@ -497,17 +482,6 @@ - - @@ -819,7 +793,21 @@ @@ -833,9 +821,10 @@ + - + @@ -853,7 +842,7 @@ - + @@ -903,16 +892,10 @@ - - - - - - - - @@ -920,13 +903,6 @@ - - - - - - - @@ -983,7 +959,6 @@ - @@ -998,6 +973,7 @@ + @@ -1109,13 +1085,6 @@ - - - - - - - @@ -1217,29 +1186,8 @@ - - - - - - - - - - - - - - - - - - - - - - - + + @@ -1257,6 +1205,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index 3812b49..0c49456 100644 --- a/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/src/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -45,6 +45,7 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD private long mNoteId; private String mSnippet; private static final int SNIPPET_PREW_MAX_LEN = 60; + //实例化播放器类 MediaPlayer mPlayer; /** @@ -54,14 +55,17 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD */ @Override protected void onCreate(Bundle savedInstanceState) { + //调用父类onCreate方法 super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); + //获取窗口 final Window win = getWindow(); //使窗口悬浮在锁屏界面上 win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); + //如果屏幕未亮起 if (!isScreenOn()) { win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON//保持屏幕常亮 | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON @@ -87,8 +91,10 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD mPlayer = new MediaPlayer(); if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) { showActionDialog(); + //播放提示音 playAlarmSound(); } else { + //结束activity finish(); } } @@ -99,9 +105,12 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD return pm.isScreenOn(); } + //播放提示音的方法 private void playAlarmSound() { + //获取默认提示音id Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM); + //是否为静音模式 int silentModeStreams = Settings.System.getInt(getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0); @@ -160,6 +169,8 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD } //该方法实现了停止闹钟铃声 + //如果实例化播放器类存在,执行操作 + //否则,跳过此方法 private void stopAlarmSound() { if (mPlayer != null) { mPlayer.stop();