I have a service that theoretically can work without an Activity associated to it (as "services" are intended on the Android platform).
This service uses Bluetooth, in particular registers a Bluetooth Service with a given Name that listens for communications. Of course to work it has to have the Bluetooth active.
As also shown on the Bluetooth api docs I'm using the
BluetoothAdapter.ACTION_REQUEST_ENABLE
to prompt the user to enable Bluetooth in case it's not on, already. This, though is an activity, and therefore needs to be called from another activity, i.e.:
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
InstanceOfAnActivity.startActivity(enableIntent);
What I would want to achieve, though, is to have the service (which, for example, starts up at boot), completely decoupled from any Activity, and therefore wouldn't have the "InstanceOfAnActivity" to start up the pop-up instructing the user to turn on Bluetooth.
Now, I know that there's the (infamous) call to BluetoothAdapter.enable()
but as the doc says it shouldn't be called directly.
So, any tip/solution to this dilemma? (Maybe it's easy and I'm just missing something...)
Thank you in advance.
~C