I'm using the Android development sample project BluetoothChat.
http://developer.android.com/resources/samples/BluetoothChat/index.html I'm running it on an Archos 43 and trying to communicate with a serial to bluetooth adapter. To communicate with the adapter I need to use UUID 00001101-0000-1000-8000-00805F9B34FB. However, when I do that, I get a Null Pointer Exception at this line: socket = mmServerSocket.accept();If I use a different UUID I do not have this problem, however I cannot connect to the serial adapter. If I use a Motorola Droid instead of the Archos 43, I do not have this problem.
From some error messages, I think the Archos is using the bluez stack.
Any ideas why the combination of this UUID and stack would cause an exception when calling the accept() function?
Here's the surrounding code (you can get the whole source from the link above)
public void run() {
if (D) Log.d(TAG, "BEGIN mAcceptThread" + this);
setName("AcceptThread");
BluetoothSocket socket = null;
// Listen to the server socket if we're not connected
while (mState != STATE_CONNECTED) {
try {
// This is a blocking call and will only return on a
// successful connection or an exception
socket = mmServerSocket.accept();
} catch (IOException e) {
Log.e(TAG, "accept() failed", e);
break;
}
Some error messsages from the开发者_如何学运维 log:
04-25 21:05:33.278: ERROR/BluetoothChatService(3321): listen() failed
04-25 21:05:33.278: ERROR/BluetoothChatService(3321): java.io.IOException: Not able to register SDP record for BluetoothChat
04-25 21:05:33.278: ERROR/BluetoothChatService(3321): at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:778)
Did you change the constructor of "class AcceptThread" , where you use this function "listenUsingRfcommWithServiceRecord()" ?
I'm using the same UUID on archos 70 and i dont get any bluetooth connection errors.( Try restarting the archos if its intermittent.) I wanted to add this as comments for some reasons i dont see a comment !
It ends up the problem was solved with a firmware update from Archos.
精彩评论