0

Alarm manager does not work on OPPO handsets if the application is closed from recent applications. I am rescheduling a service after certain interval using alarm manager with help of following source code.

     if (Build.VERSION.SDK_INT >= 23) {
        alarm.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME_WAKEUP,
                interval *
                        SystemClock.elapsedRealtime() +
                        60 * 1000 , pending);
    } else if (Build.VERSION.SDK_INT >= 19) {
        alarm.setExact(AlarmManager.ELAPSED_REALTIME_WAKEUP, interval *
                SystemClock.elapsedRealtime() +
                60 * 1000, pending);
    } else {
        alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, interval *
                SystemClock.elapsedRealtime() +
                60 * 1000, pending);
    }

This source code is working on Nexus devices, Moto devices, Samsung devices, Xiomi devices and one plus devices.

Let me know, Anyone who got the working solution with OPPO devices using Alarm manager.

Vitthalk
  • 354
  • 4
  • 10

1 Answers1

0

In My App i used below code.You may use it.Hopefully it will works fine..

if (Build.VERSION.SDK_INT >= 23)
        alarmManageram.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, calendaram.getTimeInMillis(), pentdingIntentpm);
    else
        alarmManageram.setRepeating(AlarmManager.RTC_WAKEUP, calendaram.getTimeInMillis(), AlarmManager.INTERVAL_DAY, pentdingIntentpm);

You May Also check couple of links also Link #1Link #2

Md. Zakir Hossain
  • 1,082
  • 11
  • 24