Note that there are some explanatory texts on larger screens.

plurals
  1. POAlarmManager occasionally doesn't fire alarm
    text
    copied!<p>I'm developing a live wallpaper for Android. To refresh the wallpaper at set times I use AlarmManager. Most of the times this works great, but occasionally my alarm isn't received. On top of that I can't replicate this behaviour, it just randomly happens. I've run into this using at least 3 ROMs.</p> <p>Now for the code.<br> I use this PendingIntent:</p> <pre class="lang-java prettyprint-override"><code>mRefreshIntent = new Intent() .setComponent(new ComponentName(mContext, RefreshBroadcastReceiver.class)) .setAction("my.package.name.REFRESH_WALLPAPER"); mPendingRefreshIntent = PendingIntent.getBroadcast( mContext, 0, mRefreshIntent, PendingIntent.FLAG_CANCEL_CURRENT); </code></pre> <p>This is my code to set the alarm:</p> <pre class="lang-java prettyprint-override"><code>mAlarmManager.set(AlarmManager.RTC_WAKEUP, time, mPendingRefreshIntent); </code></pre> <p>where time is the UTC time in milliseconds. I often verified if the alarm is set as intended using <code>adb shell dumpsys alarm</code>, which it is.</p> <p>The receiving side:</p> <pre class="lang-java prettyprint-override"><code>public class RefreshBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d("DayNight", "onReceive ; " + System.currentTimeMillis()); DayNightService.refresher.refresh(); Log.d("DayNight", "onReceive done; " + System.currentTimeMillis()); } } </code></pre> <p>Associated manifest lines:</p> <pre class="lang-xml prettyprint-override"><code>&lt;application&gt; ... &lt;receiver android:name="RefreshBroadcastReceiver"&gt; &lt;intent-filter&gt; &lt;action android:name="my.package.name.REFRESH_WALLPAPER" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; ... &lt;/application&gt; </code></pre> <p>Alarms which are not fired always exist in the queue (dumpsys alarms) beforehand, and are not in the alarm log afterwards. Seems like they get 'lost' at T minus zero.</p> <p>I will be very happy if one of you can solve this problem for me.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload