I am coding an app that needs to poll location at specific intervals even when the app is off. I am currently using a Firebase JobDispatcher to get the job done. The code is as follows:
BackgroundJob.schedule({
jobKey: backgroundJobKey,
period: 60000,
exact:true,
allowWhileIdle:true
});
My requirements are the following:
1) If phone is charging then the location needs to be polled continuously (which is happening)
2) If phone is stationary at the same location, then app must not poll (which is also happening when the app goes into doze mode)
3) If the phone is kept stationary in a car that is moving (or if the phone is kept stationary in someone's pocket when they are driving a bike), then the location needs to be polled continuously (which is not happening and which is the problem).
How do I get the job-dispatcher to poll when the phone is kept inside a car that is moving?