I want to have an Android device continually transmitting its location every few seconds. The location would be transmitted to a website IP so data and other things need to be kept on.
For example, I'm attaching an Android device to a bus to track its current location for a bus route.
The problem is that after a while, the device sleeps and stops transmitting the location. I would rather the solution fit different kinds of devices instead of checking the behavior on one specific device.
Another consideration is that many users will by habit close the device. Some devices like the Asus Nexus 7 will prevent all transmission to networks after a few hours to save battery. So the solution has to consider that the user will force the device to sleep, instead of simply telling the device not to sleep.
keepScreenOn
does not seem to be a suitable solution as the screen does not need to be kept on. Wake locks seem to be better suited, but ideally the device would keep the screen off but run in the background.
Another problem is that when the app is minimized or when another app is given the main thread, Android sometimes shuts the background app down and/or ends data/wireless connections to conserve battery. Is there any way to prevent apps from being closed?