How To Start A Scheduler Every 5 Minute, Without Any Fail In Android 8(Oreo) - (tried Jobscheduler Minimum Limit Is 15minutes And Is Not Reliable)
How to run a service(to perform some task) exactly every 5 minute without any fail. I had a working code for the above requirement using Alarmmanager but its failing since i am trying to target Android 8(Oreo).
- Is it possible to achieve my usecase targetting Oreo or not ?
Answer
There are lots of things in Android when put together, they won't work as expected. The problem you are facing has been solved by new WorkManager API. From official documentation:
WorkManager chooses the appropriate way to run your task based on such factors as the device API level and the app state. If WorkManager executes one of your tasks while the app is running, WorkManager can run your task in a new thread in your app's process. If your app is not running, WorkManager chooses an appropriate way to schedule a background task--depending on the device API level and included dependencies, WorkManager might use JobScheduler, Firebase JobDispatcher, or AlarmManager.
So WorkManager will take care of what to run based various factors and makes everything a lot easier and cleaner.
For your scenario, You can use recurring tasks:
https://developer.android.com/topic/libraries/architecture/workmanager#recurring
Related Questions
- → should I choose reactjs+f7 or f7+vue.js?
- → Phonegap Android write to sd card
- → Local reference jquery script in nanohttpd (Android)
- → Click to navigate on mobile devices
- → How to allow api access to android or ios app only(laravel)?
- → Access the Camera and CameraRoll on Android using React Native?
- → React native change listening port
- → What is the default unit of style in React Native?
- → Google play market autocomplete icon
- → Warning: Each child in an array or iterator should have a unique "key" prop. Check the render method of `ListView`
- → Using Laravel with Genymotion
- → react native using like web-based ajax function
- → react native pdf View