我已经创建了简单的警报应用程序。它工作得很好,但是,如果我手动更改设备的时间,那么我的闹钟就不工作了……
这是我的代码:
Calendar = Calendar.getInstance();
//c.add(Calendar.DAY_OF_WEEK,1);
c.set(Calendar.HOUR_OF_DAY,15);
c.set(Calendar.MINUTE, 00);
c.set(Calendar.SECOND, 00);
c.set(Calendar.MILLISECOND, 0);
Intent intent = new Intent(HomeActivity.this, MyAlarmService.class);
pendingIntent = PendingIntent.getService(HomeActivity.this, 0, intent, 0);
alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, c.getTimeInMillis(), pendingIntent);有什么建议吗?
发布于 2013-01-10 13:58:42
将评论中的答案添加到此处
您需要添加一个接收器来设置警报again..on日期和时区更改,然后警报得到重置,所以使用这个
<receiver android:name=".AlarmInitReceiver"> <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> <action android:name="android.intent.action.TIME_SET" /> <action android:name="android.intent.action.TIMEZONE_CHANGED" />
</intent-filter>
</receiver>https://stackoverflow.com/questions/8119215
复制相似问题