0

In my app I want the ability to continually check for Internet, Bluetooth and GPS status (if one is off/on). I need each of these to be on at all times for my application to work effectively.

  1. For the Internet, I use a Handler which checks if internet is off/on every x seconds, and I create Settings.ACTION_SETTINGS intent which the user can select to turn internet on.

  2. For the Bluetooth I have a Broadcast receiver which tells me if bluetooth is on/off and I handle it accordingly.

  3. For the GPS I use a Handler too.

The problem I have is that my MainActivity is a Google Maps Activity and my way of handling bluetooth/internet/gps is not very user friendly, an alert dialog is brought up for each separate one (when off).

I'm thinking of having one AlertDialog that controls all of bt/internet/gps. However, I'm not sure if this is even possible (I also need to connect to pair to a bluetooth device).

What would you recommend is the best way to do this?

1
  • This is a bad idea, because it eats the battery in no time.
    – Simon
    Feb 12, 2016 at 11:48

1 Answer 1

4

In my app I want the ability to continually check for Internet, Bluetooth and GPS status (if one is off/on). I need each of these to be on at all times for my application to work effectively.

It's apps like yours that continually run down my battery power...

It would be better to test once each time you fire up the app or return to it, and then better handling for when a service is off that you needed (like trying to make an internet request). Continually checking for services when you don't actually need them does nothing but eat CPU cycles and power.

As for the dialog - wrap all three service checks into a single function that informs the user the status of all three services in one dialog when any of them are off.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.