-1

i want to schedule an alarm without the AlarmManager API, because this doesn't work on my samsung device ( samsung smart manager cancel alarm), but i don't know how i can do this ?

Yass
  • 547
  • 1
  • 7
  • 14
  • 1
    ok, so instead of fixing your bugs (as alarm manager works for most people) you are going to reinwent the wheel? good luck – Marcin Orlowski Mar 10 '16 at 11:38
  • 1
    Please explain, in detail, what "schedule an alarm without the AlarmManager API" means. – CommonsWare Mar 10 '16 at 12:05
  • Thanks for your answer, i tried to fix this bug but it's the samsung smart manager the problem not my code... you can see here: http://stackoverflow.com/questions/35832166/alarmmanager-doesnt-work-on-samsung-device-with-android-lollipop-5-0-2. @CommonsWare i want to make an alarm, it works perfectly on my Motorola device (kitkat) with AlarmManager API but on my samsung device (lollipop) it doesn't work at all, i saw your answer in this post:http://stackoverflow.com/questions/35380310/alarmmanager-not-working-on-samsung-devices-in-lollipop – Yass Mar 10 '16 at 12:26
  • For people who record negatively, please understand my issue before...i know to use AlarmManager and i use it without issues on other devices but on samsung, it doesn't works, so maybe there is a different way to schedule an alarm in Android ? Thanks. – Yass Mar 10 '16 at 12:33

1 Answers1

2

If this is truly an alarm clock sort of app, there are alarm clock methods on AlarmManager that should be reliable. They will have side effects, such as bits of system UI that you can't control.

However, any other sort of on-device time-based scheduled work will be unreliable, as too many developers wasted too much battery on this sort of thing. Google and device manufacturers, based upon user complaints regarding battery life, have taken steps to limit the damage that AlarmManager can cause:

  • Android 6.0+ has Doze mode and app standby
  • SONY has their STAMINA mode
  • Samsung has their equivalent
  • And so on

Google seems to be emphasizing JobScheduler (or GcmNetworkManager, if you are using Play Services) as the preferred approach for periodic work, and you are certainly welcome to use it. However, it is only available on Android 5.0+. And, as with some aspects of AlarmManager, JobScheduler is inexact — your events will not fire at exactly the requested time, but rather at some nearby time, to help try to minimize the number of times we have to wake up the device out of a sleep mode. And JobScheduler is also affected by Doze mode and app standby on Android 6.0+.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks for your help, i will see jobScheduler (AlarmManager works well on kitkat) for my app. I tried setAlarmClock() method but it doesn't work on my device... – Yass Mar 10 '16 at 15:21
  • Thanks for your help, i will see jobScheduler (AlarmManager works well on kitkat) for my app. I tried setAlarmClock() method but it doesn't work on my device, my broadcast receiver doesn't wake up... Maybe i need a WakeFulBroadcastReceiver ? – Yass Mar 10 '16 at 15:31
  • 1
    @Yass: `WakefulBroadcastReceiver` does not help the receiver itself; it makes it possible for the receiver to pair with an `IntentService` to do more work while keeping the device awake. – CommonsWare Mar 10 '16 at 15:36