Ok, I know why both alarms are effected.  I was using
String.startsWith to check the package name in my PACKAGE_REPLACED
receiver.  So that's solved.

But, I start my Alarm in a various places to make sure it's running:

BOOT_COMPLETED
PACKAGE_REPLACED
and every time when the app itself is opened by the user, to make sure
that the alarm is running when they open it the first time around
after downloading it.

The command I use to set the alarm is:

alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis() + FIRST_TIME, AlarmManager.INTERVAL_DAY,
pendingIntent)

where FIRST_TIME is 5 minutes.  I know it may not fire for 24 hours,
but that's ok.


But I think what's happening is that every time the user starts the
app, the alarm gets recreated and it may not fire for a very long
time, by which time the app is started again and the cycle repeats.

So, long story short -- how can I make sure that the alarm is only
recreated when if it doesn't yet exist?  I don't see anything in the
AlarmManager that would let me query its state.

Thanks,
Tom




On Apr 22, 12:36 pm, Zsolt Vasvari <[email protected]> wrote:
> I have 2 apps, a paid and a free versions, using different package
> names, but the same app signature.
>
> They are both using a once-daily (non-precise) timer.  I am having
> some problems where some users are reporting that their daily timers
> don't go off.  I see something similar on my dev phone -- the timers
> sometimes goes off right after I reboot the phone, but not again.
>
> Basically, in my Phone Start receiver, I set the timer for +5 minutes
> and then after the initial firing, I set it to +24 hours.
>
> To debug, I ran a dumpsys.  Here's the relevant part:
>
>   RTC_WAKEUP #7: Alarm{408df0f8 type 0 com.zvasvari.anmoneyp}
>     type=0 when=+6h27m41s100ms repeatInterval=86400000 count=0
>     operation=PendingIntent{40a10488: PendingIntentRecord{407ff870
> com.zvasvari.anmoneyp broadcastIntent}}
>   RTC_WAKEUP #5: Alarm{406d2118 type 0 com.zvasvari.anmoney}
>     type=0 when=+3h27m41s100ms repeatInterval=86400000 count=0
>     operation=PendingIntent{406e5950: PendingIntentRecord{40831df8
> com.zvasvari.anmoney broadcastIntent}}
>
> So, one timer is supposed to fire in 6 hours, the other in 3.
>
> Next, I reinstalled the free app (com.zvasvari.anmoney).  I would have
> expected to see the free app to fire in 5 minutes, and the paid app to
> be unchanged.  But, here comes the surprise:
>
>   RTC_WAKEUP #8: Alarm{40724510 type 0 com.zvasvari.anmoneyp}
>     type=0 when=+22h11m29s486ms repeatInterval=86400000 count=0
>     operation=PendingIntent{40727388: PendingIntentRecord{407ff870
> com.zvasvari.anmoneyp broadcastIntent}}
>   RTC_WAKEUP #7: Alarm{4093eb08 type 0 com.zvasvari.anmoney}
>     type=0 when=+22h11m29s486ms repeatInterval=86400000 count=0
>     operation=PendingIntent{4052d9a8: PendingIntentRecord{40831df8
> com.zvasvari.anmoney broadcastIntent}}
>
> BOTH of my apps are now set to fire in 22 hours!!!
>
> Can somebody explain to me what's going on here?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to