AlarmManager mgr= (AlarmManager)ctxt.getSystemService(Context.ALARM_SERVICE); Intent i=new Intent(ctxt, AlarmReceiver.class); PendingIntent pi=PendingIntent.getbroadcast(ctxt, 0, i, 0);mgr.setRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, System.currentTimeMillis() + 1000, 1000, pi);
根据androID doc
triggerAtMillis time in milliseconds that the alarm should first go off, using the appropriate clock (depending on the alarm type).
该动作应该在1秒后开始,但它永远不会被调用,为什么?
解决方法:
而不是setRepeating()方法中的AlarmManager.ELAPSED_REALTIME_WAKEUP,使用如下所示的AlarmManager.RTC_WAKEUP,
mgr.setRepeating(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + 1000, 1000, pi);
总结 以上是内存溢出为你收集整理的android – 为什么AlarmManager.setRepeating中的triggerAtTime不起作用全部内容,希望文章能够帮你解决android – 为什么AlarmManager.setRepeating中的triggerAtTime不起作用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)