diff --git a/MiNote/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/MiNote/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java index ee14289..e4cba11 100644 --- a/MiNote/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java +++ b/MiNote/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java @@ -197,4 +197,5 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD mPlayer.release(); //释放MediaPlayer对象 mPlayer = null; } -} + } +} \ No newline at end of file diff --git a/MiNote/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java b/MiNote/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java index f221202..c3cf2ff 100644 --- a/MiNote/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java +++ b/MiNote/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java @@ -34,18 +34,21 @@ public class AlarmInitReceiver extends BroadcastReceiver { NoteColumns.ID, NoteColumns.ALERTED_DATE }; - + //对数据库的操作,调用标签ID和闹钟时间 private static final int COLUMN_ID = 0; private static final int COLUMN_ALERTED_DATE = 1; @Override public void onReceive(Context context, Intent intent) { long currentDate = System.currentTimeMillis(); + //System.currentTimeMillis()产生一个当前的毫秒 + //这个毫秒其实就是自1970年1月1日0时起的毫秒数 Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI, PROJECTION, NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE, new String[] { String.valueOf(currentDate) }, null); + //Cursor在这里的作用是通过查找数据库中的标签内容,找到和当前系统时间相等的标签 if (c != null) { if (c.moveToFirst()) { @@ -62,4 +65,7 @@ public class AlarmInitReceiver extends BroadcastReceiver { c.close(); } } + //然而通过网上查找资料发现,对于闹钟机制的启动,通常需要上面的几个步骤 + //如新建Intent、PendingIntent以及AlarmManager等 + //这里就是根据数据库里的闹钟时间创建一个闹钟机制 }