public class BluetoothLowEnergy {
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
public static void main(String[] args) {
System.out.println("Hello World!");
android.bluetooth.BluetoothAdapter bluetoothAdapter = android.bluetooth.BluetoothAdapter.getDefaultAdapter();
if (bluetoothAdapter != null) {
if (bluetoothAdapter.isEnabled()) {
android.bluetooth.BluetoothDevice bluetoothDevice = bluetoothAdapter.getRemoteDevice("蓝牙地址");
android.bluetooth.BluetoothSocket bluetoothSocket = bluetoothDevice.createRfcommSocketToServiceRecord(MY_UUID);
boolean cancelDiscoveryResult = bluetoothAdapter.cancelDiscovery();
java.io.InputStream inputStream = bluetoothSocket.getInputStream();
java.io.OutputStream outputStream = bluetoothSocket.getOutputStream();
}
}
}
}