Unfortunately, I have some problems with my Android phone. For my test environment, I am using Nexus 4 with Android 4.4.2.
I have a Java application on my PC that uses bluecove to connect SPP as a client. The program searches for a special service name and connects to my Android phone. Subsequently, it sends 72 bytes to my Android phone and waits for a response. When this response is received, the program sleeps for 3 seconds, and then starts again.
On my Android phone, I have an app with a bluetooth background listener that starts when it boots. This application is based on a demonstration of the BluetoothChat example. When receiving Bluetooth data, I check the incoming data and send a response.
Everything is working fine. But after 489 Bluetooth connections, the android application crashes with the following error fragment when the PC-java application is running:
getBluetoothService() called with no BluetoothManagerCallback Shutting down VM threadid=1: thread exiting with uncaught exception (group=0x41b34ba8) FATAL EXCEPTION: main Process: de.tum.lme.diamantum:remote_blue, PID: 21567 java.lang.NullPointerException: FileDescriptor must not be null at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:174) at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:905) at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:897) at android.bluetooth.IBluetooth$Stub$Proxy.createSocketChannel(IBluetooth.java:1355) at android.bluetooth.BluetoothSocket.bindListen(BluetoothSocket.java:349) at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1055) at android.bluetooth.BluetoothAdapter.listenUsingRfcommWithServiceRecord(BluetoothAdapter.java:976) at com.test.btconn.BluetoothHandling$AcceptThread.<init>(BluetoothHandling.java:449) at com.test.btconn.BluetoothHandling.start(BluetoothHandling.java:216) at com.test.btconn.BluetoothListenerService.setupBtSockets(BluetoothListenerService.java:330) at com.test.btconn.BluetoothListenerService.manageBtState(BluetoothListenerService.java:249) at com.test.btconn.BluetoothListenerService.setBtStateDisconnected(BluetoothListenerService.java:383) at com.test.btconn.BluetoothListenerService.access$5(BluetoothListenerService.java:378) at com.test.btconn.BluetoothListenerService$2.handleMessage(BluetoothListenerService.java:421)
Therefore, the application has problems with ParcelFileDescriptor, which is unexpectedly null. But why?
Everything described above also occurs when the pause time is changed on a PC-java application, using different data sizes for transferring and using different smartphones. Using the reflection "listenUsingRfcommWithServiceRecord" the same thing happens after 505 transfers. Also, using wakelock does not change anything.
By the way, I have the same behavior when using the BluetoothChat sample.
So, is there any hint of what's going on?
Update:
BluetoothServerSocket closes after each connection and BluetoothSocket if bluetooth status is 3.
java android bluetooth spp
user3073364
source share