3
Bluetooth入力ストリームのreadLineにタイムアウトを挿入する必要があります。Android:BluetoothSocket readLine timeout
BluetoothDevice device = BluetoothAdapter.getDefaultAdapter()
.getRemoteDevice("00:00:00:00:00:00");
sock = device.createInsecureRfcommSocketToServiceRecord(UUID
.fromString(insecureUUID));
sock.connect();
in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
String line = in.readLine(); //if no answer from device..i'll wait here forever
do { [...]
} while ((line = in.readLine()) != null);
接続はうまくいきますが、別のデバイスにリンクされたBluetoothシリアルコンバータがあります。 2番目のものがオフになっている場合、私はreadLineで永遠に待つでしょう。私は例外やタイムアウトをスローする可能性は何ですか? ありがとうございます!