0

I have made myself familiar with how services work and how Bluetooth works. My code already works if I am in the app, but I want it to also work when it is not open.

So I basically want to make a service. When I am running the app I simply open a Bluetoothsocket and wait until the other device sends that it's ready.

Here are my questions:

  1. Would opening a Bluetoothsocket with a device in the service as long as it's nearby be a big battery issue?

  2. Is there any downside to leaving the socket up?

  3. Would listening to an Inputstream the whole day drain a lot of battery? I assume so, and if yes is there a better way to activate the service?

  • Register a broadcast like this https://stackoverflow.com/a/24888208/5502638 and run your service when bluetooth ON – Akash Dubey Jul 28 '17 at 10:38
  • I could make a broadcastreceiver that would run the onReceive function only if something is actually sent and all the time when a device is connected, right? – JDoeKnought Jul 28 '17 at 10:44
  • It will run the Method defined by you which i assume will run bacground service for executing your background task whenever you want like BluetoothAdapter.STATE_ON or BluetoothAdapter.STATE_OFF – Akash Dubey Jul 28 '17 at 10:46
  • Ok thanks. My problem is that I don't want to run it the whole time Bluetooth is On but only when it is actually receiving an Inputstream. I could of course make the service check that the whole time, but that sounds like it's horrible for battery life. – JDoeKnought Jul 28 '17 at 10:52
  • From Where It will receive inputStream then!! – Akash Dubey Jul 28 '17 at 10:53

0 Answers0