Android Bluetooth开发总结-----/*自己编写*/

来源:互联网 发布:淘宝套现信用卡手续费 编辑:程序博客网 时间:2024/06/10 07:51

1. 开启手机的蓝牙适配器    

// 当地的蓝牙适配器private BluetoothAdapter mBluetoothAdapter = null;// 得到当地的蓝牙适配器mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();// 手机蓝牙适配器获取错误,弹出提示窗口if (mBluetoothAdapter == null) {<span style="white-space:pre"></span>Toast.makeText(this, "can't find bluetooth adapter", Toast.LENGTH_LONG).show();finish();return;}//手机蓝牙功能如果没开选择开启if (!mBluetoothAdapter.isEnabled()) {mBluetoothAdapter.enable();   // 系统会弹出选择开启蓝牙的提示框}

2. 

0 0
原创粉丝点击