Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7861465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:45:03+00:00 2026-06-02T22:45:03+00:00

Ok so the issue here that I have a video camera which is connected

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T22:45:05+00:00Added an answer on June 2, 2026 at 10:45 pm

    Binyamin Sharet’s answer was good but unfortunately it didn’t solve my problem because when the application is no longer visible or in use it may still be running, and it takes quite awhile for the application to actually shut down. The other thing to note is when your service/listener or any other component is started up that will instantiate your Application class which can make things tricky.

    Perhaps I worded my question poorly. However what I wanted was to prevent my application from attempting to re-establish connection while it was actively open (or being used).

    This proved to be much easier to accomplish by simply writing to shared preferences the state (busy/not busy) and checking that in my code that ran from alarm manager. It was a bit of extra state to maintain which I didn’t want but really wasn’t too difficult.

    I used commonsware wakeful intent to wake up every minute and do the following:

    1. Check if application is controlling this (from shared prefs), if so exit
    2. Check if bluetooth is on, if not exit
    3. Bind to the service which talks to the device and check if one is already connected, if so exit
    4. If no devices connected (but there is a device paired) then attempt to connect

    Although I may be able to optimize this some it seems to work and be pretty fail proof. I know it’s not great for the battery but I still don’t see my application in the list of apps using my battery (although android seems to be using more).

    The only real improvements I can think of are:

    1. If I’m already connected stop waking the service up every minute
      until it is disconnected.
    2. when bluetooth is disabled stop waking up the service. Once it is re-enabled start trying to reconnect every minute again. I believe there is a way to be notified when bluetooth is enabled by using intent filters.

    For simplicity I have not implemented these yet though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I am stuck with a peculiar issue here. I have a script that basically
Ok, very very weird issue here. I have a sub nav menu that links
I'm seeing basically the same issue described here I have a table that starts
Here's the issue: I have 2 data contexts that I would like to do
Here's the issue: I have a hook in IE that reacts on WebBrowser.OnNavigateComplete2 event
Here's the issue: I have a list of App names that I want to
Here is the issue I am having: I have a large query that needs
So here's my issue. I have an image that I need to shrink. The
Here is my issue. I have an array containing the name of cities that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.