Android - AlarmClock 鬧鐘 特定時間 週期
會用到AlarmManager主要是安排應用程序在將來的某個時間運行 今天在開發時,將AlarmManager cancel後,AlarmManager 功能卻還會執行......這這這到底怎麼一回事? 我的程式碼 新增 Intent intent = new Intent(); intent.setAction("MyAlarmClock"); PendingIntent sender = PendingIntent.getBroadcast(mContext, 0, intent, 0); long firstTime = SystemClock.elapsedRealtime(); firstTime += firstSecond * 1000; AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); am.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, firstTime, intervalSecond * 1000, sender); 停止 Intent intent = new Intent(); intent.setAction("MyAlarmClock"); PendingIntent sender = PendingIntent.getBroadcast(mContext, 0, intent, 0); ...