title: Android Programming: Bluetooth connection refused on OS Version 4.1.1
body: <p>In android application we are using Bluetooth connectivity with some of medical devices. </p>
  
  <p>To do this we have used below code</p>
  
  <pre><code>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));
  </code></pre>
  
  <p>or some condition, if the above code get failed then we use below code</p>
  
  <pre><code>String bluetooth_address="";
  bluetooth_address=bluetoothAddress;
  BluetoothDevice zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(bluetooth_address);
  result = zee.createRfcommSocketToServiceRecord( getSerialPortUUID() );
  </code></pre>
  
  <p>both codes are working fine up to 4.0 android OS.</p>
  
  <p>But on Android OS 4.1.1 it is now getting issue like “<code>Connection Refused</code>”.</p>
  
  <p>Please help.</p>