내 앱에서 Bluetooth를 사용하는 중에 문제가 있습니다. 28 BluetoothSocket
/BluetoothServerSockets
을 만든 후에 모든 포트가 사용 된 것 같습니다. 소켓을 동시에 열 필요는 없으며 Bluetooth가 활성화 된 이후로 소켓이 28 개 밖에 없습니다.Android : Bluetooth에서 포트 번호를 가져 오지 못했습니다.
Android Samples에 제공된 BluetoothChat 샘플을 사용하여 재생할 수 있습니다. 간단히 열어서 앱을 15 번 닫습니다 (앱은 매회 2 개의 소켓을 만듭니다). 15 시간에, 그것은 충돌하고 블루투스를 재 활성화 한 다음 비활성화 될 때까지 충돌이 계속됩니다
12-06 18:43:58.177: E/BluetoothSocket(18530): bindListen, fail to get port number, exception: java.io.IOException: read failed, socket might closed, read ret: -1
12-06 18:43:58.193: E/BluetoothChatService(18530): Socket Type: Insecurelisten() failed
12-06 18:43:58.193: E/BluetoothChatService(18530): java.io.IOException: Error: -1
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.bluetooth.BluetoothAdapter.createNewRfcommSocketAndRecord(BluetoothAdapter.java:1035)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.bluetooth.BluetoothAdapter.listenUsingInsecureRfcommWithServiceRecord(BluetoothAdapter.java:982)
12-06 18:43:58.193: E/BluetoothChatService(18530): at com.example.android.BluetoothChat.BluetoothChatService$AcceptThread.<init>(BluetoothChatService.java:280)
12-06 18:43:58.193: E/BluetoothChatService(18530): at com.example.android.BluetoothChat.BluetoothChatService.start(BluetoothChatService.java:119)
12-06 18:43:58.193: E/BluetoothChatService(18530): at com.example.android.BluetoothChat.BluetoothChat.onResume(BluetoothChat.java:131)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1185)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.Activity.performResume(Activity.java:5182)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2732)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2771)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2235)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.os.Handler.dispatchMessage(Handler.java:99)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.os.Looper.loop(Looper.java:137)
12-06 18:43:58.193: E/BluetoothChatService(18530): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-06 18:43:58.193: E/BluetoothChatService(18530): at java.lang.reflect.Method.invokeNative(Native Method)
12-06 18:43:58.193: E/BluetoothChatService(18530): at java.lang.reflect.Method.invoke(Method.java:511)
12-06 18:43:58.193: E/BluetoothChatService(18530): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-06 18:43:58.193: E/BluetoothChatService(18530): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-06 18:43:58.193: E/BluetoothChatService(18530): at dalvik.system.NativeStart.main(Native Method)
소켓이 닫힌 후 포트를 확보 할 수있는 방법이 있습니까?
감사합니다. 여기에 버그를 제출했습니다. [# 41110] (http://code.google.com/p/android/issues/detail?id=41110). Galaxy Nexus와 4.2.1을 실행하는 Nexus 7 모두에서 앱이 다운되는 데 15 번 걸렸습니다. 내 넥서스 원은 결코 추락하지 않았으므로 단지 JB 문제 일뿐입니다. – mattprecious