gpt4 book ai didi

android - 警报管理器准确性

转载 作者:太空宇宙 更新时间:2023-11-03 13:31:03 24 4
gpt4 key购买 nike

如何在准确的时间间隔使用报警管理器?

我使用了警报管理器,但它的响应不准确。谁能帮我?我使用了这段代码

PendingIntent sender;
AlarmManager am;
long firstTime;
Intent itnt = new Intent();
itnt.setAction("abts.medismo.medismo.ALARMRECEIVER");
sender = PendingIntent.getBroadcast(context, 0,itnt, 0);
am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
am.cancel(sender);
firstTime = SystemClock.elapsedRealtime();
am.setInExactRepeating(AlarmManager.ELAPSED_REALTIME,firstTime, Integer.parseInt(sep[3]), sender);

最佳答案

您应该使用 ELAPSED_REALTIME_WAKEUP,因为如果手机处于 sleep 状态,它不会触发直到再次唤醒。

关于android - 警报管理器准确性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13190998/

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