1. Are you ready for the Galaxy S20? Here is everything we know so far!

setExactAndAllowWhileIdle not reliable

Discussion in 'Android Development' started by mhogan, Dec 16, 2019.

  1. mhogan

    mhogan Lurker
    Thread Starter

    Has anyone successfully gotten setExactAndAllowWhileIdle (Alarm Manager) to work reliably? I'm making an alarm clock app and it's pretty important to have the alarm fire at the desired time. I'm using the Alarm Manager to call a Service which I then call startForeground() immediately in the on Create() method and request a wakeLock(). I'm using it to chime on the hour and half hour. I invariably miss two or three alarms a day. Sometimes I won't get an alert for a couple hours and then magically it will start working again.

    I think this might be related to battery conservation but everything I've read says that setExactAndAllowWhileIdle will ALWAYS trigger at the desired time (plus or minus a few milliseconds).

    I'm happy to provide more info but I'm not looking for anyone to write my code for me. I just want a friendly nudge in the right direction.

    I should mention that this seems to work properly in the emulator but not on real-world devices. I've tested it with a Samsung Galaxy Tab S6 and a Google Pixel C Tablet and both exhibit the problem I've described.
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...

Share This Page

Loading...