AlarmManager在Android上,将不会触发任何东西

编程入门 行业动态 更新时间:2024-10-25 04:14:22
本文介绍了AlarmManager在Android上,将不会触发任何东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图使Android火灾报警在一定的时间,用户指定检查用户是否发布到服务。但是,Android将不火的意图。

I'm trying to make Android fire a Alarm at a certain time the user specifies to check if the user has posted to the service. However, Android won't fire the intent.

AndroidManifest.xml中:

AndroidManifest.xml:

<receiver android:name="me.kennydude.dailybooth.NoBoothNotify.AlarmReciever" /> <service android:name="me.kennydude.dailybooth.NoBoothNotify.AlarmService"> </service>

NoBoothNotify.java功能设置报警:

NoBoothNotify.java function that sets the alarm:

public static void settingsChanged(){ Context cntxt = DailyboothApplication.getInstance(); String value = DailyboothShared.getPersonalSetting("noBoothNotify", "no"); AlarmManager alm = (AlarmManager) cntxt.getSystemService(Context.ALARM_SERVICE); Intent piI = new Intent(cntxt, AlarmReciever.class); if(Build.VERSION.SDK_INT >= 5){ SharedPreferences prefs = DailyboothShared.getPrefs(); piI.putExtra("account", prefs.getString("current_account", null)); } PendingIntent pi = PendingIntent.getBroadcast(cntxt, 348347873, piI, PendingIntent.FLAG_UPDATE_CURRENT); if(value.equals("no")){ alm.cancel(pi); } else{ String[] values = value.split(":"); Calendar cal = Calendar.getInstance(); Log.d("s", value); // cal.setTimeInMillis(System.currentTimeMillis()); cal.clear(Calendar.HOUR_OF_DAY); cal.clear(Calendar.SECOND); cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(values[0])); cal.set(Calendar.MINUTE, Integer.parseInt(values[1])); cal.setTimeZone(TimeZone.getTimeZone("GMT")); Log.d("s", "setting for " + cal.getTimeInMillis()); Log.d("s", "HRD: " + cal.getTime().toGMTString()); alm.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), /*AlarmManager.INTERVAL_DAY,*/ pi); } }

正如你可以看到我试图刚刚得到它的工作一(因此注释掉的部分),但它不仍能正常工作。

As you can see I'm trying to just get it working one (hence the commented out part), however it doesn't work still.

谁能帮助?

谢谢,

推荐答案

我似乎已经解决了这个问题。出于某种原因,Android不喜欢火灾报警器,如果接收器是一个子类。

I seem to have fixed this. For some reason Android doesn't like to fire Alarms if the receiver is a subclass.

要修复并保持起源,我这一切搬到一个新的命名空间和它的工作。

To fix and keep origination, I moved it all to a new namespace and it worked.

更多推荐

AlarmManager在Android上,将不会触发任何东西

本文发布于:2023-11-27 01:37:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636045.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:东西   AlarmManager   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!