Page 77 - MDP2022-2
P. 77
Button up;
Button left;
Button down;
Button right;
Button STOP;
BluetoothAdapter mBluetoothAdapter;
Set<BluetoothDevice> mPairedDevices;
List<String> mListPairedDevices;
Handler mBluetoothHandler;
ConnectedBluetoothThread mThreadConnectedBluetooth;
BluetoothDevice mBluetoothDevice;
BluetoothSocket mBluetoothSocket;
final static int BT_REQUEST_ENABLE = 1;
final static int BT_MESSAGE_READ = 2;
final static int BT_CONNECTING_STATUS = 3;
final static UUID BT_UUID = UUID.fromString("00001101-0000-1000-8000-00805F
9B34FB");
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mTvBluetoothStatus = (TextView) findViewById(R.id.tvBluetoothStatus);
mBtnBluetoothOn = (Button) findViewById(R.id.btnBluetoothOn);
mBtnBluetoothOff = (Button) findViewById(R.id.btnBluetoothOff);
mBtnConnect = (Button) findViewById(R.id.btnConnect);
up=(Button) findViewById(R.id.bt_up);
left=(Button) findViewById(R.id.bt_left);
right=(Button) findViewById(R.id.bt_right);
down=(Button) findViewById(R.id.bt_down);
STOP=(Button) findViewById(R.id.bt_STOP);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBtnBluetoothOn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
bluetoothOn();