ps: android调用蓝牙进行系列的操作……
1、检测蓝牙开启
BluetoothAdapter bluetoothAdapter;
/**获取蓝牙管理对象*/
BluetoothManager bluetoothManager= (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE);
if (bluetoothManager!=null){
bluetoothAdapter=bluetoothManager.getAdapter();
}
/**检测蓝牙是否可用*/
public void checkBluetoothDev(Context context){
if (bluetoothAdapter!=null){
if (!bluetoothAdapter.isEnabled()){
Intent enableBIntent=new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
/**可用直接直接打开蓝牙*/
enableBIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(enableBIntent);
}
}else{
Toast.makeText(context, "手机不支持蓝牙!", Toast.LENGTH_LONG).show();
}
}
2、获取已配对列表
3、获取范围内蓝牙列表
4、进行蓝牙配对
参考
http://blog.csdn.net/yehui928186846/article/details/52710112