转载        源码下载地址

经过最近一段时间得研究,针对网上给出的案例。总结了一个亲测好使的Demo。

说明如下:

1、本Demo用来连接蓝牙设备HC-05,如果你要连接其他蓝牙设备,注意修改相关名字以及修改设备初试pin值。

2、将Demo安装在Android手机上,点击按钮,可以实现与目标蓝牙设备的自动配对。

3、若目标蓝牙设备为Android手机的蓝牙,则只能保证本设备不弹出配对框,对方还是会弹出配对框。但是!!不管目标蓝牙点击“确认”or“取消”,在本设备中都显示已经成功配对。实测表明,确实已经配对了,可以进行数据传输。

4、由于使用了广播机制,所以需要在Androidmanifest.xml进行如下配置。

先配置蓝牙使用权限:

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

然后配置action,将需要用到的广播进行注册

<receiver android:name="com.ywq.broadcast.BluetoothReceiver" >
    <intent-filter android:priority="1000">
        <action android:name="android.bluetooth.device.action.PAIRING_REQUEST"/>
        <action android:name="android.bluetooth.device.action.FOUND" />
    </intent-filter>
</receiver>

程序运行流程:

1、点击按钮,判断蓝牙是否打开,,执行bluetoothAdapter.startDiscovery();由本地蓝牙设备扫描远程蓝牙设备,startDiscovery()方法是一个异步方法,调用后立即返回。该方法会进行蓝牙设备的搜索,持续12秒。

2、搜索时,系统会发送3个广播,分别为:ACTION_DISCOVERY_START:开始搜索 、ACTION_DISCOVERY_FINISHED:搜索结束、 ACTION_FOUND:找到设备,该Intent中包含两个extra fields;

3、在广播接收类中BluetoothReceiver.Java中,当设备找到之后会执行其onReceive方法。

4、String action = intent.getAction(); //得到action,

第一次action的值为BluetoothDevice.ACTION_FOUND,当找到的设备是我们目标蓝牙设备时,调用createBond方法来进行配对。ClsUtils.createBond(btDevice.getClass(), btDevice);该方法执行后,系统会收到一个请求配对的广播,即android.bluetooth.device.action.PAIRING_REQUEST。最后进行自动配对操作。

5、配对操作借助工具类ClsUtils.java得到了Android蓝牙API中隐藏的方法,实现自动配对,不弹出配对框的功能。

代码如下:

MainActivity.java

[java] view plaincopy print?
  1. package com.example.mybuletooth;
  2. import android.app.Activity;
  3. import android.bluetooth.BluetoothAdapter;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.widget.Button;
  8. public class MainActivity extends Activity implements OnClickListener{
  9. /** Called when the activity is first created. */
  10. private Button autopairbtn=null;
  11. private BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. autopairbtn=(Button) findViewById(R.id.button1);
  17. autopairbtn.setOnClickListener(this);
  18. }
  19. //设置按钮的监听方法
  20. @Override
  21. public void onClick(View arg0) {
  22. if (!bluetoothAdapter.isEnabled())
  23. {
  24. bluetoothAdapter.enable();//异步的,不会等待结果,直接返回。
  25. }else{
  26. bluetoothAdapter.startDiscovery();
  27. }
  28. }
  29. }
package com.example.mybuletooth;import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class MainActivity extends Activity implements OnClickListener{/** Called when the activity is first created. */ private Button autopairbtn=null;private BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);autopairbtn=(Button) findViewById(R.id.button1);autopairbtn.setOnClickListener(this);}//设置按钮的监听方法@Overridepublic void onClick(View arg0) {if (!bluetoothAdapter.isEnabled()){bluetoothAdapter.enable();//异步的,不会等待结果,直接返回。}else{bluetoothAdapter.startDiscovery();}}
}

BluetoothReceiver.java

[java] view plaincopy print?
  1. package com.ywq.broadcast;
  2. import com.ywq.tools.ClsUtils;
  3. import android.bluetooth.BluetoothDevice;
  4. import android.content.BroadcastReceiver;
  5. import android.content.Context;
  6. import android.content.Intent;
  7. import android.util.Log;
  8. public class BluetoothReceiver extends BroadcastReceiver{
  9. String pin = "1234";  //此处为你要连接的蓝牙设备的初始密钥,一般为1234或0000
  10. public BluetoothReceiver() {
  11. }
  12. //广播接收器,当远程蓝牙设备被发现时,回调函数onReceiver()会被执行
  13. @Override
  14. public void onReceive(Context context, Intent intent) {
  15. String action = intent.getAction(); //得到action
  16. Log.e("action1=", action);
  17. BluetoothDevice btDevice=null;  //创建一个蓝牙device对象
  18. // 从Intent中获取设备对象
  19. btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
  20. if(BluetoothDevice.ACTION_FOUND.equals(action)){  //发现设备
  21. Log.e("发现设备:", "["+btDevice.getName()+"]"+":"+btDevice.getAddress());
  22. if(btDevice.getName().contains("HC-05"))//HC-05设备如果有多个,第一个搜到的那个会被尝试。
  23. {
  24. if (btDevice.getBondState() == BluetoothDevice.BOND_NONE) {
  25. Log.e("ywq", "attemp to bond:"+"["+btDevice.getName()+"]");
  26. try {
  27. //通过工具类ClsUtils,调用createBond方法
  28. ClsUtils.createBond(btDevice.getClass(), btDevice);
  29. } catch (Exception e) {
  30. // TODO Auto-generated catch block
  31. e.printStackTrace();
  32. }
  33. }
  34. }else
  35. Log.e("error", "Is faild");
  36. }else if(action.equals("android.bluetooth.device.action.PAIRING_REQUEST")) //再次得到的action,会等于PAIRING_REQUEST
  37. {
  38. Log.e("action2=", action);
  39. if(btDevice.getName().contains("HC-05"))
  40. {
  41. Log.e("here", "OKOKOK");
  42. try {
  43. //1.确认配对
  44. ClsUtils.setPairingConfirmation(btDevice.getClass(), btDevice, true);
  45. //2.终止有序广播
  46. Log.i("order...", "isOrderedBroadcast:"+isOrderedBroadcast()+",isInitialStickyBroadcast:"+isInitialStickyBroadcast());
  47. abortBroadcast();//如果没有将广播终止,则会出现一个一闪而过的配对框。
  48. //3.调用setPin方法进行配对...
  49. boolean ret = ClsUtils.setPin(btDevice.getClass(), btDevice, pin);
  50. } catch (Exception e) {
  51. // TODO Auto-generated catch block
  52. e.printStackTrace();
  53. }
  54. }else
  55. Log.e("提示信息", "这个设备不是目标蓝牙设备");
  56. }
  57. }
  58. }
package com.ywq.broadcast;import com.ywq.tools.ClsUtils;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;public class BluetoothReceiver extends BroadcastReceiver{String pin = "1234";  //此处为你要连接的蓝牙设备的初始密钥,一般为1234或0000public BluetoothReceiver() {}//广播接收器,当远程蓝牙设备被发现时,回调函数onReceiver()会被执行 @Overridepublic void onReceive(Context context, Intent intent) {String action = intent.getAction(); //得到actionLog.e("action1=", action);BluetoothDevice btDevice=null;  //创建一个蓝牙device对象// 从Intent中获取设备对象btDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); if(BluetoothDevice.ACTION_FOUND.equals(action)){  //发现设备Log.e("发现设备:", "["+btDevice.getName()+"]"+":"+btDevice.getAddress());if(btDevice.getName().contains("HC-05"))//HC-05设备如果有多个,第一个搜到的那个会被尝试。{if (btDevice.getBondState() == BluetoothDevice.BOND_NONE) {  Log.e("ywq", "attemp to bond:"+"["+btDevice.getName()+"]");try {//通过工具类ClsUtils,调用createBond方法ClsUtils.createBond(btDevice.getClass(), btDevice);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}elseLog.e("error", "Is faild");}else if(action.equals("android.bluetooth.device.action.PAIRING_REQUEST")) //再次得到的action,会等于PAIRING_REQUEST{Log.e("action2=", action);if(btDevice.getName().contains("HC-05")){Log.e("here", "OKOKOK");try {//1.确认配对ClsUtils.setPairingConfirmation(btDevice.getClass(), btDevice, true);//2.终止有序广播Log.i("order...", "isOrderedBroadcast:"+isOrderedBroadcast()+",isInitialStickyBroadcast:"+isInitialStickyBroadcast());abortBroadcast();//如果没有将广播终止,则会出现一个一闪而过的配对框。//3.调用setPin方法进行配对...boolean ret = ClsUtils.setPin(btDevice.getClass(), btDevice, pin);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}elseLog.e("提示信息", "这个设备不是目标蓝牙设备");}}
}

工具类ClsUtils.java

[java] view plaincopy print?
  1. package com.ywq.tools;
  2. /************************************ 蓝牙配对函数 * **************/
  3. import java.lang.reflect.Method;
  4. import java.lang.reflect.Field;
  5. import android.bluetooth.BluetoothDevice;
  6. import android.util.Log;
  7. public class ClsUtils
  8. {
  9. /**
  10. * 与设备配对 参考源码:platform/packages/apps/Settings.git
  11. * /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
  12. */
  13. static public boolean createBond(Class btClass, BluetoothDevice btDevice)
  14. throws Exception
  15. {
  16. Method createBondMethod = btClass.getMethod("createBond");
  17. Boolean returnValue = (Boolean) createBondMethod.invoke(btDevice);
  18. return returnValue.booleanValue();
  19. }
  20. /**
  21. * 与设备解除配对 参考源码:platform/packages/apps/Settings.git
  22. * /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java
  23. */
  24. static public boolean removeBond(Class<?> btClass, BluetoothDevice btDevice)
  25. throws Exception
  26. {
  27. Method removeBondMethod = btClass.getMethod("removeBond");
  28. Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice);
  29. return returnValue.booleanValue();
  30. }
  31. static public boolean setPin(Class<? extends BluetoothDevice> btClass, BluetoothDevice btDevice,
  32. String str) throws Exception
  33. {
  34. try
  35. {
  36. Method removeBondMethod = btClass.getDeclaredMethod("setPin",
  37. new Class[]
  38. {byte[].class});
  39. Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice,
  40. new Object[]
  41. {str.getBytes()});
  42. Log.e("returnValue", "" + returnValue);
  43. }
  44. catch (SecurityException e)
  45. {
  46. // throw new RuntimeException(e.getMessage());
  47. e.printStackTrace();
  48. }
  49. catch (IllegalArgumentException e)
  50. {
  51. // throw new RuntimeException(e.getMessage());
  52. e.printStackTrace();
  53. }
  54. catch (Exception e)
  55. {
  56. // TODO Auto-generated catch block
  57. e.printStackTrace();
  58. }
  59. return true;
  60. }
  61. // 取消用户输入
  62. static public boolean cancelPairingUserInput(Class<?> btClass,
  63. BluetoothDevice device)  throws Exception
  64. {
  65. Method createBondMethod = btClass.getMethod("cancelPairingUserInput");
  66. //        cancelBondProcess(btClass, device);
  67. Boolean returnValue = (Boolean) createBondMethod.invoke(device);
  68. return returnValue.booleanValue();
  69. }
  70. // 取消配对
  71. static public boolean cancelBondProcess(Class<?> btClass,
  72. BluetoothDevice device)
  73. throws Exception
  74. {
  75. Method createBondMethod = btClass.getMethod("cancelBondProcess");
  76. Boolean returnValue = (Boolean) createBondMethod.invoke(device);
  77. return returnValue.booleanValue();
  78. }
  79. //确认配对
  80. static public void setPairingConfirmation(Class<?> btClass,BluetoothDevice device,boolean isConfirm)throws Exception
  81. {
  82. Method setPairingConfirmation = btClass.getDeclaredMethod("setPairingConfirmation",boolean.class);
  83. setPairingConfirmation.invoke(device,isConfirm);
  84. }
  85. /**
  86. *
  87. * @param clsShow
  88. */
  89. static public void printAllInform(Class clsShow)
  90. {
  91. try
  92. {
  93. // 取得所有方法
  94. Method[] hideMethod = clsShow.getMethods();
  95. int i = 0;
  96. for (; i < hideMethod.length; i++)
  97. {
  98. Log.e("method name", hideMethod[i].getName() + ";and the i is:"
  99. + i);
  100. }
  101. // 取得所有常量
  102. Field[] allFields = clsShow.getFields();
  103. for (i = 0; i < allFields.length; i++)
  104. {
  105. Log.e("Field name", allFields[i].getName());
  106. }
  107. }
  108. catch (SecurityException e)
  109. {
  110. // throw new RuntimeException(e.getMessage());
  111. e.printStackTrace();
  112. }
  113. catch (IllegalArgumentException e)
  114. {
  115. // throw new RuntimeException(e.getMessage());
  116. e.printStackTrace();
  117. }
  118. catch (Exception e)
  119. {
  120. // TODO Auto-generated catch block
  121. e.printStackTrace();
  122. }
  123. }
  124. }
package com.ywq.tools;/************************************ 蓝牙配对函数 * **************/import java.lang.reflect.Method;
import java.lang.reflect.Field;
import android.bluetooth.BluetoothDevice;
import android.util.Log;  public class ClsUtils
{  /** * 与设备配对 参考源码:platform/packages/apps/Settings.git * /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java */  static public boolean createBond(Class btClass, BluetoothDevice btDevice)  throws Exception  {  Method createBondMethod = btClass.getMethod("createBond");  Boolean returnValue = (Boolean) createBondMethod.invoke(btDevice);  return returnValue.booleanValue();  }  /** * 与设备解除配对 参考源码:platform/packages/apps/Settings.git * /Settings/src/com/android/settings/bluetooth/CachedBluetoothDevice.java */  static public boolean removeBond(Class<?> btClass, BluetoothDevice btDevice)  throws Exception  {  Method removeBondMethod = btClass.getMethod("removeBond");  Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice);  return returnValue.booleanValue();  }  static public boolean setPin(Class<? extends BluetoothDevice> btClass, BluetoothDevice btDevice,  String str) throws Exception  {  try  {  Method removeBondMethod = btClass.getDeclaredMethod("setPin",  new Class[]  {byte[].class});  Boolean returnValue = (Boolean) removeBondMethod.invoke(btDevice,  new Object[]  {str.getBytes()});  Log.e("returnValue", "" + returnValue);  }  catch (SecurityException e)  {  // throw new RuntimeException(e.getMessage());  e.printStackTrace();  }  catch (IllegalArgumentException e)  {  // throw new RuntimeException(e.getMessage());  e.printStackTrace();  }  catch (Exception e)  {  // TODO Auto-generated catch block  e.printStackTrace();  }  return true;  }  // 取消用户输入  static public boolean cancelPairingUserInput(Class<?> btClass,  BluetoothDevice device)  throws Exception  {  Method createBondMethod = btClass.getMethod("cancelPairingUserInput");
//        cancelBondProcess(btClass, device);Boolean returnValue = (Boolean) createBondMethod.invoke(device);  return returnValue.booleanValue();  }  // 取消配对  static public boolean cancelBondProcess(Class<?> btClass,  BluetoothDevice device)  throws Exception  {  Method createBondMethod = btClass.getMethod("cancelBondProcess");  Boolean returnValue = (Boolean) createBondMethod.invoke(device);  return returnValue.booleanValue();  } //确认配对static public void setPairingConfirmation(Class<?> btClass,BluetoothDevice device,boolean isConfirm)throws Exception {Method setPairingConfirmation = btClass.getDeclaredMethod("setPairingConfirmation",boolean.class); setPairingConfirmation.invoke(device,isConfirm);}/** * * @param clsShow */  static public void printAllInform(Class clsShow)  {  try  {  // 取得所有方法  Method[] hideMethod = clsShow.getMethods();  int i = 0;  for (; i < hideMethod.length; i++)  {  Log.e("method name", hideMethod[i].getName() + ";and the i is:"  + i);  }// 取得所有常量  Field[] allFields = clsShow.getFields();  for (i = 0; i < allFields.length; i++)  {  Log.e("Field name", allFields[i].getName());  }}  catch (SecurityException e)  {  // throw new RuntimeException(e.getMessage());  e.printStackTrace();  }  catch (IllegalArgumentException e)  {  // throw new RuntimeException(e.getMessage());  e.printStackTrace();  }  catch (Exception e)  {  // TODO Auto-generated catch block  e.printStackTrace();  }  }
}

Androidmanifest.xml

[html] view plaincopy print?
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.example.mybuletooth"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6. <uses-sdk
  7. android:minSdkVersion="8"
  8. android:targetSdkVersion="21" />
  9. <uses-permission android:name="android.permission.BLUETOOTH"/>
  10. <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
  11. <application
  12. android:allowBackup="true"
  13. android:icon="@drawable/ic_launcher"
  14. android:label="@string/app_name"
  15. android:theme="@style/AppTheme" >
  16. <activity
  17. android:name=".MainActivity"
  18. android:label="@string/app_name" >
  19. <intent-filter>
  20. <action android:name="android.intent.action.MAIN" />
  21. <category android:name="android.intent.category.LAUNCHER" />
  22. </intent-filter>
  23. </activity>
  24. <receiver android:name="com.ywq.broadcast.BluetoothReceiver" >
  25. <intent-filter android:priority="1000">
  26. <action android:name="android.bluetooth.device.action.PAIRING_REQUEST"/>
  27. <action android:name="android.bluetooth.device.action.FOUND" />
  28. </intent-filter>
  29. </receiver>
  30. </application>
  31. </manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.mybuletooth"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="8"android:targetSdkVersion="21" /><uses-permission android:name="android.permission.BLUETOOTH"/><uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><activityandroid:name=".MainActivity"android:label="@string/app_name" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><receiver android:name="com.ywq.broadcast.BluetoothReceiver" ><intent-filter android:priority="1000"><action android:name="android.bluetooth.device.action.PAIRING_REQUEST"/><action android:name="android.bluetooth.device.action.FOUND" /></intent-filter></receiver></application></manifest>

布局配置文件activity_main.xml

[html] view plaincopy print?
  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:paddingBottom="@dimen/activity_vertical_margin"
  6. android:paddingLeft="@dimen/activity_horizontal_margin"
  7. android:paddingRight="@dimen/activity_horizontal_margin"
  8. android:paddingTop="@dimen/activity_vertical_margin"
  9. tools:context="com.example.mybuletooth.MainActivity" >
  10. <Button
  11. android:id="@+id/button1"
  12. android:layout_width="wrap_content"
  13. android:layout_height="wrap_content"
  14. android:layout_alignParentLeft="true"
  15. android:layout_alignParentTop="true"
  16. android:layout_marginLeft="54dp"
  17. android:layout_marginTop="56dp"
  18. android:text="自动配对" />
  19. <TextView
  20. android:id="@+id/textView1"
  21. android:layout_width="wrap_content"
  22. android:layout_height="wrap_content"
  23. android:layout_centerVertical="true"
  24. android:text="点击按钮,自动搜索蓝牙设备,并且进行配对" />
  25. </RelativeLayout>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"android:paddingBottom="@dimen/activity_vertical_margin"android:paddingLeft="@dimen/activity_horizontal_margin"android:paddingRight="@dimen/activity_horizontal_margin"android:paddingTop="@dimen/activity_vertical_margin"tools:context="com.example.mybuletooth.MainActivity" ><Buttonandroid:id="@+id/button1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentLeft="true"android:layout_alignParentTop="true"android:layout_marginLeft="54dp"android:layout_marginTop="56dp"android:text="自动配对" /><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_centerVertical="true"android:text="点击按钮,自动搜索蓝牙设备,并且进行配对" /></RelativeLayout>

针对网上其它帖子中的demo不好使的原因,在此给出一些我的看法,是不是这样不敢保证,至少部分是这些原因吧。。。

1、出现一个一闪而过的配对框怎么办?

答:那是因为广播没有停止,须得调用abortBroadcast();将广播停止。

2、自动配对框还是会弹出来怎么办?

答:网上好多帖子代码有误,或者没有说清楚。请注意相关配置和工具类中函数的使用。

这是本人亲测好使的自动配对Demo,仅供参考,希望对大家有所帮助。有问题可以联系我。

重要更新:********************************************************************************

2016-10-20 ,今天和一个咨询我的小伙伴详细的聊了会儿天。他的问题是,下图所示的if语句块进不去。

它的btDevice.getBondState( )=12,但是BluetoothDevice.BOND_NONE=10,这不是肯定进不去么。

其中,查阅SDK,可以看到BluetoothDevice的这几个函数和数字的含义是什么。

参考网址:http://www.cnblogs.com/over140/archive/2010/12/21/1912482.html

如下所示:

我一看,天呐,很明显的低级错误。我让他打开设置看看,是否显示已经配对。结果自然是已经配对了。

产生原因:这个demo在跑之前,他已经在手机-设置-蓝牙中手动把目标蓝牙配对了。那还玩个毛呀

当手动取消配对后,程序运行正常,log打印和预期一样,自动配对实现。

提示:

通过这个小失误,可以看出,评论里好多说这也不行,那也不行的。既然好多人都说好使,那你为什么就不行呢?还是多从自身找问题吧,心思缜密点,避免这种低级失误。大哥,你是程序猿好不好。

Android下的蓝牙自动配对相关推荐

  1. android 实现ble蓝牙自动配对连接

    蓝牙自动配对,即搜索到其它蓝牙设备之后直接进行配对,不需要弹出配对确认框或者密钥输入框. 本文章用来连接蓝牙设备ai-thinker,如果你要连接其他蓝牙设备,注意修改相关名字以及修改设备初试pin值 ...

  2. 【转载】Android蓝牙自动配对Demo

    注:新版本安卓需增加权限 <uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION ...

  3. android蓝牙配对 自动联接,Android系统下蓝牙自动配对连接方法

    Android系统下蓝牙自动配对连接方法 [专利摘要]本发明涉及一种Android系统下蓝牙自动配对连接方法,其包括如下步骤:步骤1.在Android设备端内存储上次进行蓝牙连接蓝牙外设的蓝牙地址,并 ...

  4. 蓝牙自动配对警惕PIN码漏洞攻击

    蓝牙自动配对警惕PIN码漏洞攻击 配对是蓝牙设备间身份认证的一个过程,只有成功配对的两个设备才能连接并进行数据交互,所以配对是蓝牙操作中必不可少的流程. 在<蓝牙配对协议分析一>和< ...

  5. w10添加蓝牙显示无法连接服务器失败,技术解答Win10系统下显示蓝牙已配对但未连接的修复方式...

    电脑已经成为了大家生活中不可或缺的东西,而且基本上所有的用户电脑都安装了windows系统,操作系统的过程中往往会遇到一些问题,就比如Win10系统下显示蓝牙已配对但未连接的情况,如果你的电脑技术不够 ...

  6. android 实现蓝牙自动配对连接,Android实践 -- Android蓝牙设置连接

    蓝牙开发相关 使用Android Bluetooth APIs将设备通过蓝牙连接并通信,设置蓝牙,查找蓝牙设备,配对蓝牙设备 连接并传输数据,以下是Android系统提供的蓝牙相关的类和接口 Blue ...

  7. android源码灭屏时蓝牙自动配对

    1.android4.4/packages/apps/Settings/src/com/android/settings/bluetooth/BluetoothPairingDialog.java 添 ...

  8. android开发之蓝牙主动配对连接手机

    上一篇介绍了手机配对连接的三种方式,这篇以完整的一个代码实例介绍如何搜索周围的蓝牙设备,以及主动配对,连接. 主要注释在代码中都有. package jason.com; import java.io ...

  9. 【Android】蓝牙开发——经典蓝牙:配对与解除配对 实现配对或连接时不弹出配对框

    目录 一.配对方法 二.解除配对方法 三.配对/解除配对结果 四.justwork配对模式下,不弹出配对框 五.pincode配对模式下,不弹出配对框 六.小结 在之前的文章[Android]蓝牙开发 ...

最新文章

  1. 查看文件more、less
  2. js如何获取文本节点的值?
  3. IIS+ASP+MySQL8.0+数据库连接解决方案(2019.7)
  4. css transform Y旋转 dom隐藏
  5. 批作业是小学老师的一大乐趣 | 今日最佳
  6. 你女朋友在买买买时,程序员小哥在干嘛?
  7. Python+OpenGL实现物体快速运动时的模糊效果
  8. 最大频偏和最大相位偏移_振荡器的相位噪声模型
  9. Visual Studio 2010 Beta版包括InstallShield Limited Edition
  10. java用正则表达式大全_Java 正则表达式 大全
  11. Http状态代码指示
  12. maven配置阿里云镜像
  13. Echarts 3d地球toolstips实现
  14. Jar包常见的反编译工具介绍与使用
  15. MFC 16 进制HEX显示控件
  16. (初学笔记1)python读多波段遥感影像并存到三维数组中
  17. ProxySQL 配置详解及读写分离(+GTID)等功能说明2 (完整篇)
  18. Linux命令教程第三期
  19. java传递指针_Java:通过指针传递参数
  20. Tensorflow C++使用ops::BatchMatMul实现特征批量乘法

热门文章

  1. google之Thumbnails图片等比压缩,保持图片清晰
  2. SAP HANA XS ODATA使用参数展示数据结构
  3. HANA XS Administration Tool登录参数设置
  4. oracle mysql迁移方案_Oracle/云MySQL/MsSQL“大迁移”真相及最优方案
  5. 苹果手机smtp服务器没有响应,smtp服务器没有响应
  6. 魅力主播曹启泰《上班这点事》经典语录
  7. 黑产以及一般业务安全的应对思路
  8. linux 网络错误代码,Linux版本登录提示网络错误
  9. java读取txt文件乱码解决方案
  10. DSP28377s系统时钟配置注意事项