Ok so the issue here that I have a video camera which is connected to a phone via Bluetooth. All communication with the device is via an android Service. The Service periodically updates the camera with GPS coordinates. The service unfortunately is not written by my company and we only have control over starting it and sending it commands (however it does the GPS on its own, if connected to a device). Once the service is started by our application we try to connect to any paired devices that contain my companies OUI. Once a device disconnects (maybe its turned off or battery runs out), it will not be automatically reconnected until the user re-launches our application. Thus GPS coordinates will not get sent to the camera in that scenario.
This is a problem because the user (who doesn't know anything about these services and what not) would think if he turned the device back on it should be connected.
So I was thinking I could use AlarmManager with a broadcast receiver or a service (probably an intent service because the connection takes several seconds to complete). Perhaps once ever few minutes I could check for a connection to the camera. If its present just quit, and if not attempt to connect (if there are paired devices).
However the problem is what if my application is already running? If it is then the user controls connecting to the device (they are prompted for it). Do I need to use shared preferences or something like that to tell if my application is running/shut down? Is there any way to tell from a service if the application is running? I can see this getting tricky. If anyone has ideas how to handle this let me know.