51

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.

2
  • check this: stackoverflow.com/questions/17304479/… Commented Sep 11, 2013 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
    Commented Mar 3, 2016 at 3:26

6 Answers 6

48

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

2
  • i got this error cannot resolve method getBluetoothService(null)
    – Makvin
    Commented Jul 5, 2017 at 10:13
  • You should not call the method directly. It is package private. Use the public Connect() method.
    – AndreasPK
    Commented Jul 28, 2017 at 8:36
8

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.

2
  • 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
    Commented Jan 22, 2015 at 16:26
  • 30
    This answer is as useful as a politician.
    – GeneCode
    Commented Mar 23, 2019 at 4: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.

3
  • 1
    in android 4.2 this is a known issue Commented Apr 27, 2013 at 20:51
  • Ah ok, tnx for the info :) Commented Apr 29, 2013 at 7:20
  • 1
    Also some phones using the broadcom bluetooth stack : / Commented Apr 29, 2013 at 22:57
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.

-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

4

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.