49

I am getting getBluetoothService() called with no BluetoothManagerCallback as an error frequently in my Android application.

I have no idea what is causing this or anything about bluetooth manager callbacks. Can anyone give me a good idea of what could be causing this problem or where to start looking.

Martin Zeitler
  • 1
  • 19
  • 155
  • 216
dacopenhagen
  • 2,414
  • 2
  • 23
  • 29
  • check this: http://stackoverflow.com/questions/17304479/android-getbluetoothservice-called-with-no-bluetoothmanagercallback – user2723096 Sep 11 '13 at 13:12
  • Note that it's an exceptionally stupid message. The software should know whether the socket is closed or has had a read timeout, and the two conditions aren't remotely similar. I suspect 'socket is closed' should read 'connection has been closed by the peer'. – user207421 Mar 03 '16 at 03:26

6 Answers6

45

By reading into the Android source code, it seems to be a warning you cannot do anything about. The source code shows that if you call

BluetoothSocket#connect();

Then it will call

BluetoothAdapter.getDefaultAdapter().getBluetoothService(null);

The key here, is the null parameter that it passes in the above line. Due to this, there will be no callback, and then the BluetoothSocket class will throw out a warning.

Since it is only a warning, I do not think you need to do anything about it.

https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothSocket.java line 306 https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/bluetooth/BluetoothAdapter.java line 1610

AndreasPK
  • 643
  • 5
  • 7
9

It appears that this gets called when multiple bluetooth sockets are opened at once. I fixed this by ensuring I was only opening 1 socket at a time.

dacopenhagen
  • 2,414
  • 2
  • 23
  • 29
  • 16
    Can you clarify how you do this (just in words). I have a function that "Closes All Open Sockets" that I call just before I open a new socket. Though, this doesn't seem to do the trick. How are you doing it? – Brandon Jan 22 '15 at 16:26
  • 29
    This answer is as useful as a politician. – GeneCode Mar 23 '19 at 04:33
3

I get this error even after my application has been closed and I can't get rid of it in any possible way. After this start happening I need to hard-reboot my phone because I'm not able anymore to even turn ON bluetooth.

Right now (with the same code) it happens only on one of my phones.. maybe it's an issues of the drivers.

Vittorio Cozzolino
  • 931
  • 1
  • 14
  • 31
0

This also comes up if the BluetoothServerSocket isn't currently accepting [bluetoothServerSocket.accept()] with the same UUID you are trying to connect.

If you are sure you are accepting with the server socket, double check that you haven't provided a too short timeout (I had previously set it to 200 to check something, whoops).

0

I received this message after trying to BluetoothSocket.connect() directly after receiving the BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED with a state of BluetoothHeadset.STATE_CONNECTED. The BluetoothSocket.connect() also failed. After adding a timeout of 500ms before trying to BluetoothSocket.connect() this resolved my issue of actually connecting. The message "getBluetoothService() called with no BluetoothManagerCallback" still remains but everything works.

Pepijn
  • 1,439
  • 17
  • 16
-2

getBluetoothService() called with no BluetoothManagerCallback

I am also facing the same problem. But I solved. In my case already one socket is in open state and I am trying to open another socket. So we trying to open more than one socket at a time as a client. I felt that this is the reason

Kona Suresh
  • 1,836
  • 1
  • 15
  • 25