I have a service that can theoretically work without an action associated with it (since the βservicesβ are for the Android platform).
This service uses Bluetooth, in particular, registers a Bluetooth service with the given name, which listens to messages. Of course, for it to work, it must have active Bluetooth.
As also shown in the api docs bluetooth, I use BluetoothAdapter.ACTION_REQUEST_ENABLEto prompt the user to turn on bluetooth if it is not already on. This, however, is an activity and therefore must be called from another action, that is:
Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
InstanceOfAnActivity.startActivity(enableIntent);
What I would like to achieve is to have a service (which, for example, starts at boot) that is completely separate from any Activity, and therefore will not have InstanceOfAnActivityBluetooth turned on to start a pop-up briefing.
Now I know that there is a (notorious) call BluetoothAdapter.enable(), but since the document says that it cannot be called directly.
So, any advice / solution to this dilemma? (Maybe it's easy, and I just missed something ...)
cloud source
share