gpt4 book ai didi

安卓 : AlarmManager triggers anytime

转载 作者:行者123 更新时间:2023-11-29 17:49:48 25 4
gpt4 key购买 nike

我有以下一段代码,应该在 2 天后触发警报。然而,它每 2 小时就会触发一次,一些用户说他们也每 5 分钟就会触发一次。

settingDB.updateSetting("Notification",1);
Calendar Calendar_Object = Calendar.getInstance();
Calendar_Object.set(Calendar.HOUR_OF_DAY, 10);
Calendar_Object.set(Calendar.MINUTE,01);
Calendar_Object.set(Calendar.SECOND, 0);
//Calendar_Object.set(Calendar.DAY_OF_WEEK, 1);

// MyView is my current Activity, and AlarmReceiver is the
// BoradCastReceiver

Intent myIntent = new Intent(Setting.this, TimeAlarm.class);

PendingIntent pendingIntent = PendingIntent.getBroadcast(Setting.this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);

AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
//Log.w("alarm set for " , Calendar_Object.getTime().toString ());

/*
* The following sets the Alarm in the specific time by getting the long
* value of the alarm date time which is in calendar object by calling
* the getTimeInMillis(). Since Alarm supports only long value , we're
* using this method.
* 3*1000*24*3600
*/

//alarmManager.setRepeating(AlarmManager.RTC, Calendar_Object.getTimeInMillis(),3600*1000**24,pendingIntent);

alarmManager.setRepeating(AlarmManager.RTC, Calendar_Object.getTimeInMillis(), 86400000*2, pendingIntent);

你能帮我解决这个问题吗?

最佳答案

传递给警报管理器的日历对象设置为固定时间。这将使警报在该时间到来时响起。

关于安卓 : AlarmManager triggers anytime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23718736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com