私は Bluetooth チャット サンプルを使用しており、デバイスをペアリングして、あるデバイスから別のデバイスにテキストを送信することは完全に問題ありませんが、時々切断され、最後に接続されたデバイスに再接続したいと思います。これを達成するにはどうすればよいですか。自動接続を試しましたプレイストアからのBluetoothですが、ヘッドセットとアプリ内からではなくアプリ外から接続します。
アプリ内からこれを達成するにはどうすればよいですか?
前もって感謝します。
E/BluetoothChatService(10175): accept() failed
E/BluetoothChatService(10175): java.io.IOException: Operation Canceled
E/BluetoothChatService(10175): at android.bluetooth.BluetoothSocket.acceptNative(Native Method)
E/BluetoothChatService(10175): at android.bluetooth.BluetoothSocket.accept(BluetoothSocket.java:311)
E/BluetoothChatService(10175): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:107)
E/BluetoothChatService(10175): at android.bluetooth.BluetoothServerSocket.accept(BluetoothServerSocket.java:93)
E/BluetoothChatService(10175): at com.example.android.BluetoothChat.BluetoothChatService$AcceptThread.run(BluetoothChatService.java:276)
E/BluetoothChatService(10175): disconnected
E/BluetoothChatService(10175): java.io.IOException: Software caused connection abort
E/BluetoothChatService(10175): at android.bluetooth.BluetoothSocket.readNative(Native Method)
E/BluetoothChatService(10175): at android.bluetooth.BluetoothSocket.read(BluetoothSocket.java:333)
E/BluetoothChatService(10175): at android.bluetooth.BluetoothInputStream.read(BluetoothInputStream.java:96)
E/BluetoothChatService(10175): at java.io.InputStream.read(InputStream.java:163)
E/BluetoothChatService(10175): at com.example.android.BluetoothChat.BluetoothChatService$ConnectedThread.run(BluetoothChatService.java:436)
E/AndroidRuntime(10175): FATAL EXCEPTION: Thread-1274
E/AndroidRuntime(10175): java.lang.NullPointerException
E/AndroidRuntime(10175): at com.example.android.BluetoothChat.BluetoothChatService.connectionLost(BluetoothChatService.java:242)
E/AndroidRuntime(10175): at com.example.android.BluetoothChat.BluetoothChatService.access$6(BluetoothChatService.java:221)
E/AndroidRuntime(10175): at com.example.android.BluetoothChat.BluetoothChatService$ConnectedThread.run(BluetoothChatService.java:443)E/BluetoothChat(10175): - ON PAUSE -