We are running some alarm services in the background and it's working in Oreo emulator, but on a real device it is not working. Can anyone tell why my code fails?
val alarmIntent = Intent(this, NetworkChangeReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT)
val calendar = Calendar.getInstance()
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.MINUTE, 1)
val manager = getSystemService(Context.ALARM_SERVICE) as AlarmManager
manager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.timeInMillis, 1000 * 60, pendingIntent)
another option is using work manager but it's working only every 15 min.
Background services it's not working in some devices like Vivo : ColorOs OnePlus : OxygenOs MI : FunTouchOs . . . .
More information check this below url.
https://stackoverflow.com/a/52373492/7387028