Android examples for android.bluetooth:Bluetooth
get Insecure Rfcomm Socket By Reflection
import android.annotation.TargetApi; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; import android.bluetooth.BluetoothGattCharacteristic; import android.bluetooth.BluetoothGattDescriptor; import android.bluetooth.BluetoothSocket; import android.os.Build; import java.lang.reflect.Method; import java.util.UUID; public class Main{ private static synchronized BluetoothSocket getInsecureRfcommSocketByReflection( BluetoothDevice device) throws Exception { if (device == null) return null; Method m = device.getClass().getMethod( "createInsecureRfcommSocket", new Class[] { int.class }); return (BluetoothSocket) m.invoke(device, 1); }//from w w w.java2 s . co m }