@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
//获取蓝牙适配器
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}
@OnClick({R.id.btn_start, R.id.btn_stop, R.id.btn_search, R.id.btn_discoverable})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_start:
bluetoothAdapter.enable();
Toast.makeText(MainActivity.this,"蓝牙已打开",Toast.LENGTH_SHORT).show();
break;
case R.id.btn_stop:
bluetoothAdapter.disable();
Toast.makeText(MainActivity.this,"蓝牙已关闭",Toast.LENGTH_SHORT).show();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
//获取蓝牙适配器
bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
}
@OnClick({R.id.btn_start, R.id.btn_stop, R.id.btn_search, R.id.btn_discoverable})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_start:
bluetoothAdapter.enable();
Toast.makeText(MainActivity.this,"蓝牙已打开",Toast.LENGTH_SHORT).show();
break;
case R.id.btn_stop:
bluetoothAdapter.disable();
Toast.makeText(MainActivity.this,"蓝牙已关闭",Toast.LENGTH_SHORT).show();