80,475
社区成员
发帖
与我相关
我的任务
分享 // Activity中的代码;设置每2分钟启动,在Button点击后启动
long firstTime = SystemClock.elapsedRealtime();
// Schedule the alarm!
AlarmManager am = (AlarmManager)getSystemService(ALARM_SERVICE);
am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,
firstTime, 2*60*1000, mAlarmSender);// 获取当前时间(精确到毫秒), 格式为: yyyy-mm-dd hh:mm:ss.nnn
String currentTime = new java.sql.Timestamp(System.currentTimeMillis()).toString();
new ReadAndWrite().WriteTxtFile(
Environment.getExternalStorageDirectory()
+ "/MyAlarmManager.log",
currentTime
+ ":am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, 2*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第"
+ (++count) + "次");
startMyActivity("com.austin.myalarmmanager",
"com.austin.myalarmmanager.PopUpDisplay");2013-09-23 02:22:18.785:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第20次
2013-09-23 02:24:18.788:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第21次
2013-09-23 02:25:45.717:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第22次
2013-09-23 02:29:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第23次
2013-09-23 02:33:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第24次
2013-09-23 02:37:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第25次
2013-09-23 02:41:45.719:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第26次
2013-09-23 02:45:45.716:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第27次
2013-09-23 02:49:45.725:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第28次
2013-09-23 02:53:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第29次
2013-09-23 02:57:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第30次
2013-09-23 03:01:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第31次
2013-09-23 03:05:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第32次2013-09-23 07:41:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第89次
2013-09-23 07:43:45.71:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第90次
2013-09-23 07:45:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第91次
2013-09-23 07:47:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第92次
2013-09-23 07:51:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第93次
2013-09-23 08:13:45.716:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第94次
2013-09-23 08:17:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第95次
2013-09-23 08:21:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第96次
2013-09-23 08:25:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第97次
2013-09-23 08:29:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第98次
2013-09-23 08:33:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第99次
2013-09-23 08:37:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第100次2013-09-24 03:03:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第343次
2013-09-24 03:07:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第344次
2013-09-24 03:11:45.711:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第345次
2013-09-24 03:15:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第346次
2013-09-24 03:19:45.71:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第347次
2013-09-24 03:23:45.716:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第348次
2013-09-24 03:27:45.723:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第349次
2013-09-24 03:31:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第350次
2013-09-24 03:35:45.711:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第351次
2013-09-24 03:39:45.769:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第352次
2013-09-24 03:43:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第353次
2013-09-24 03:47:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第354次
2013-09-24 03:51:45.715:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第355次
2013-09-24 03:55:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第356次
2013-09-24 03:59:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第357次
2013-09-24 04:03:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第358次
2013-09-24 04:07:45.719:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第359次
2013-09-24 04:11:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第360次
2013-09-24 04:15:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第361次
2013-09-24 04:19:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第362次
2013-09-24 04:23:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第363次
2013-09-24 04:27:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第364次
2013-09-24 04:31:45.716:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第365次
2013-09-24 04:35:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第366次
2013-09-24 04:39:45.713:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第367次
2013-09-24 04:43:45.773:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第368次
2013-09-24 04:47:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第369次
2013-09-24 04:49:45.71:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第370次
2013-09-24 04:53:45.714:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第371次
2013-09-24 04:57:45.712:am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime, TIME*60*1000, mAlarmSender);(每隔2分钟)启动Service一次,本次为第372次我用的是AlarmManager.RTC_WAKEUP 模式完全可以按照设定的频率来
的确是有点怪的,你在 service 里又调用 startMyActivity 干嘛,定时器已经是循环状态了,不需要再次调用。
的确是有点怪的,你在 service 里又调用 startMyActivity 干嘛,定时器已经是循环状态了,不需要再次调用。