Page 577 - MDP2020-1
P. 577
················································································ 명장양성프로젝트 【MDP】 과제발표회 자료집 Ⅰ | 571
public class ButtonActivity extends AppCompatActivity {
TextView warning;
Button mBtnBluetoothOn;
Button mBtnBluetoothOff;
Button mBtnConnect,userplus;
Button mBtnSendData;
BluetoothAdapter mBluetoothAdapter;
Set<BluetoothDevice> mPairedDevices;
List<String> mListPairedDevices;
Handler mBluetoothHandler;
ButtonActivity.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-00805F9B34FB");
@SuppressLint("HandlerLeak")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_button);
mBtnBluetoothOn = findViewById(R.id.btnBluetoothOn);
mBtnBluetoothOff = findViewById(R.id.btnBluetoothOff);
mBtnConnect = findViewById(R.id.btnConnect);
mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
warning = findViewById(R.id.warning);
mBtnBluetoothOn.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
bluetoothOn();
}
});
mBtnBluetoothOff.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View view) {
bluetoothOff();