Androidアプリケーションでは、一部の医療機器でBluetooth接続を使用しています。
これを行うために、以下のコードを使用しました
BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetoothAddress);
Method m = (Method) zee.getClass().getMethod("createRfcommSocket",new Class[] { int.class });
result = (BluetoothSocket) m.invoke(zee, Integer.valueOf(1));
または何らかの条件で、上記のコードが失敗した場合は、以下のコードを使用します
String bluetooth_address="";
bluetooth_address=bluetoothAddress;
BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetooth_address);
result = zee.createRfcommSocketToServiceRecord( getSerialPortUUID() );
どちらのコードも、4.0androidOSまでは正常に機能しています。
しかし、Android OS 4.1.1では、「<code>ConnectionRefused」のような問題が発生しています。
助けてください。