总结昨天进度:
1.昨天对课前提醒的基本框架已经搭好,剩下的就是对如何提醒进行设置
遇到的困难:
1.在一些细节地方,代码有点犯浑,将Preferences的文件写错了,导致在用switch开关得到时候一直启动有错误。
今天的任务:
1,完成课前提醒功能
当日总结:
1.最后的决定是用activity来实现闹钟的功能,即在到达时间的时候,启动一个新的activity,并添加弹窗提示,添加背景音乐,点击确认之后关闭音乐,关闭震动,关闭activity,但是还没有全部完成
public class SetRemindService extends Service { @Override public IBinder onBind(Intent intent) { return null; } @Override public void onCreate() { super.onCreate(); } public int onStartCommand(Intent intent, int flags, int startId) { final int sum=Preferences.getInt("TodayLessonSum",0); if(sum>0) { Log.d("课前提醒",".."); new Timer().schedule(new TimerTask() { @Override public void run() { int nowTime=TimeUtils.getSetQuietTime(); Log.d("当前时间数值",nowTime+""); for(int i=1;i<=sum;i++) { int setRemindTime=changeRemindTimeSummer(Preferences.getInt(i+"-1",1)); if(nowTime==setRemindTime) { Intent alarm=new Intent(getApplicationContext(),AlarmActivity.class); alarm.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK ); startActivity(alarm); } } } }, 0, 60000); } return super.onStartCommand(intent, flags, startId); } public int changeRemindTimeSummer(int time) { switch (time) { case 1: return 750; case 2: return 840; case 3: return 940; case 4: return 1030; case 5: return 1120; case 6: return 1420; case 7: return 1510; case 8: return 1610; case 9: return 1700; case 10: return 1850; case 11: return 1940; case 12: return 2030; } return 0; } }