このトピックについて多くのことが書かれていますが、私はまだ私の特定の問題の解決策を見つけることができません:
SasmsungGalaxySIIIをシンプルなBluetoothデバイスに接続しようとしています。電話のBluetooth設定(PINは不要)を使用してこれら2つをペアリングすると、機能します。ただし、以前にデバイスを手動でペアリングしたことがない場合は、次の例外が発生します。
java.io.IOException: Service discovery failed
at android.bluetooth.BluetoothSocket$SdpHelper.doSdp(BluetoothSocket.java:462)
at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:240)
at com.concept.proiv.BluetoothConnection$1.run(BluetoothConnection.java:84)
at java.lang.Thread.run(Thread.java:856)
関連コード:
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) ...
if (!mBluetoothAdapter.isEnabled()) ...
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice("00:0A:3A:2F:7C:1A");
try
{
btSocket = device.createInsecureRfcommSocketToServiceRecord(MY_UUID);
}
catch (IOException e) ... - WORKING
mBluetoothAdapter.cancelDiscovery();
try
{
btSocket.connect(); <-- FAILED HERE
}
catch (IOException e)
{
e.printStackTrace(); //java.io.IOException: Service discovery failed
}