getbluetoothservice() called with no bluetoothmanagercallback

前端 未结 6 1464
遇见更好的自我
遇见更好的自我 2020-12-03 16:30

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

I have no idea what is caus

相关标签:
6条回答
  • 2020-12-03 17:04

    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

    0 讨论(0)
  • 2020-12-03 17:10

    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.

    0 讨论(0)
  • 2020-12-03 17:10

    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.

    0 讨论(0)
  • 2020-12-03 17:14

    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 讨论(0)
  • 2020-12-03 17:18

    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.

    0 讨论(0)
  • 2020-12-03 17:19

    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

    0 讨论(0)
提交回复
热议问题