当前位置:   article > 正文

android 蓝牙调用_安卓蓝牙调用

安卓蓝牙调用

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();
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20

2、获取已配对列表

3、获取范围内蓝牙列表

4、进行蓝牙配对

参考
http://blog.csdn.net/yehui928186846/article/details/52710112

http://www.jianshu.com/p/3a372af38103

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小惠珠哦/article/detail/956230
推荐阅读
相关标签
  

闽ICP备14008679号