Android Bluetopth 编程大牛文章

http://my.oschina.net/u/994235/blog?catalog=313604













ViewGroup 相关资料 :

http://www.incoding.org/admin/archives/199.html

http://bbs.csdn.net/topics/370144745

http://www.linuxidc.com/Linux/2013-01/78109.htm

http://blog.csdn.net/arui319/article/details/5868466

http://www.2cto.com/kf/201109/104633.html

http://www.cnblogs.com/slider/archive/2011/11/24/2262161.html




蓝牙开发指南 :

http://wenku.baidu.com/view/b41c1b09bb68a98271fefae1.html


蓝牙编程 :

http://wenku.baidu.com/link?url=QT1NMnkqNk3Emm_CueUyqtawXyQ2-CNIu5Es6xgtbj2KLUe5Cu5mXo2xDbvnBRLuvH044uiF2Vhcwjz4o8uCdkYYiUV3R71Id4GIdEQsPLe






http://blog.csdn.net/qinjuning/article/details/7726093BluetoothAdapter类简介

http://www.cnblogs.com/over140/archive/2010/12/21/1912460.html

Android 中文API (69) —— BluetoothAdapter[蓝牙]

http://www.wuphone.com/579.htmlBluetoothAdapter蓝牙

http://www.cnblogs.com/over140/archive/2010/12/21/1912482.html

BluetoothDevice[蓝牙]


http://blog.csdn.net/forlong401/article/details/8536209

android蓝牙开发——基本概念



http://blog.csdn.net/hellogv/article/details/6042091十三篇之探秘蓝牙隐藏API

http://www.cnblogs.com/wanqieddy/archive/2013/05/24/3096312.html隐藏api介绍

http://www.eoeandroid.com/thread-18993-1-1.html?_dsign=d70c243dAndroid蓝牙开发浅谈

http://blog.csdn.net/myarrow/article/details/8143717安卓设备待机广播


http://www.cnblogs.com/fbsk/archive/2011/10/10/2205316.html

Android开机自启动程序


http://wenku.baidu.com/view/6baf53eaaeaad1f346933f85.html

http://android.toolib.net/reference/android/bluetooth/BluetoothServerSocket.html

BlueToothServerSocket API解析


http://jinguo.iteye.com/blog/687357

http://android.toolib.net/reference/android/bluetooth/BluetoothSocket.html

BlueToothSocket API解析


http://blog.csdn.net/xiluoduyu/article/details/8515286

http://www.linuxidc.com/Linux/2012-09/69586.htm

蓝牙模块开发


使用代码打开蓝牙

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
System.out.println(" 打开蓝牙 ");
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);


http://my.oschina.net/billowworld/blog/62975

如何实现android蓝牙开发 自动配对连接,并不弹出提示框


http://www.eoeandroid.com/thread-249231-1-1.html蓝牙取消配对方法

http://blog.csdn.net/zzy916853616/article/details/6597746 android开发之蓝牙初步 扫描已配对蓝牙、更改蓝牙可见性、搜索外部蓝牙设备


Android中通过静态注册的屏幕开启和屏幕关闭的BroadCastReceiver为什么捕捉不到广播?

  • kandee

    -1 票

  • 1

android开发中使用AndroidManiFest.xml静态注册的BroadCastReceiver没有作用是什么原因?

使用静态注册,Debug运行,就是没进到onReceive()方法那里去。我用真机调试的。

但是使用动态注册,又可以捕捉到。我想问,这个系统广播可不可以静态注册?如果可以为什么会捕捉不到呢?


在Android 的广播机制中,动态注册的优先级是要高于静态注册优先级的,你是否在调试时2个都注册了,所以出现你的这种情况;当用来注册动态广播接收器的activity被关闭时,这个动态接收器也就是就失效了,静态注册的广播接收器只要有你注册的广播出现就能接收到广播。


对于这两个action:

android.intent.action.SCREEN_OFF
android.intent.action.SCREEN_ON

在AndroidManifest.xml中注册是不可以的。

这有点不同于其他的action,你只有在Service中通过动态注册去监听这个事件。

这个问题我的理解是google故意这么做的,有两点考虑:
1.提高监听screen_on screen_off门槛
这两个事件是android的基本事件,如果呗大多数程序监听,会大大的拖慢整个系统,所以android也应该不鼓励我们在后台监听这两个事件。

2.有让我们在service后台监听
这也是提供了一个解决问题,强调和service共存亡,不会一直在后台无限情运行。

总之应该是为了保证系统的稳定和安全才采取这样的措施。
希望对你有帮助。



蓝牙配对密码设置

先是写个
<receiver android:name=".broadcast.PairingRequest">
<intent-filter>
<action android:name="android.bluetooth.device.action.PAIRING_REQUEST" />
<action android:name="android.bluetooth.device.action.PAIRING_CANCEL" />
</intent-filter>
</receiver>

然后是你的
public class PairingRequest extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent){
if (intent.getAction().equals("ACTION_PAIRING_REQUEST")) {
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
byte[] pinBytes = BluetoothDevice.convertPinToBytes("1234");
device.setPin(pinBytes);
}
}
}

其中的蓝牙BluetoothDevice这个类要用源码里的替换下

蓝牙设备是怎么连接的

最前提的条件是有蓝牙的MAC地址; String macAddress;

根据蓝牙的MAC地址 , 可以获得蓝牙设备BluetoothDevice对象 , BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);

将蓝牙设备对象传入服务中的connect方法中;

将设备连接放在线程中完成 , 创建一个设备连接的线程 , 启动这个线程.



BluetoothAdapter资料 :

关于权限资料

 android.permission.BLUETOOTH允许程序连接到已配对的蓝牙设备(Allows applications to connect to paired bluetooth devices)
  android.permission.BLUETOOTH_ADMIN允许程序发现和配对蓝牙设备(Allows applications to discover and pair bluetooth devices)


android蓝牙开发——权限

为了在应用程序中使用蓝牙功能,我们至少需要声明两方面的权限:BLUETOOTH和BLUETOOTH_ADMIN。

你必须请求BLUETOOTH权限才能够实现蓝牙通信,例如请求一个连接、接受一个连接和传输数据。

你必须请求BLUETOOTH_ADMIN权限,才能够初始化device discovery或者管理蓝牙设置(Bluetooth settings)。大多数应用程序必须具有这个权限才能够发现本地蓝牙设备,这个权限保护的其他能力(除了发现本地设备)不应该被使用,除非你的应用程序是在用户请求的时候能够修改蓝牙设置的管理者。

注意:如果你想要使用BLUETOOTH_ADMIN权限,那么你首先必须有BLUETOOTH权限。

你需要在应用程序的manifest文件中声明程序的蓝牙权限。例如:

[xhtml] view plain copy
  1. <manifest...>
  2. <uses-permissionandroid:name="android.permission.BLUETOOTH"/>
  3. ...
  4. </manifest>

关于声明应用程序权限的信息,请看<uses-permission>参考。
















更多相关文章

  1. Android清理设备内存具体完整演示样例(一)
  2. 如何在Android 11 中正确请求位置权限?以及Android 8 - 11位置权
  3. Android BLE学习(二): Android与51822蓝牙模块通信流程的实现与分析
  4. android 蓝牙4.0广播功能应用
  5. android M上可能需要开发者注意的权限大全
  6. Android蓝牙操作
  7. Android bluetooth介绍(二): android 蓝牙代码架构及其uart 到rfcom
  8. android apk获得系统权限
  9. Android Bluetooth 学习(2)应用层实现蓝牙设备查找、tcp_ip通信

随机推荐

  1. Android电池管理系统系统分析
  2. Android开发规范(编码+性能+UI)
  3. Android触摸事件机制
  4. 将一个Android项目作为另一个Android(安
  5. 享受Android应用程序的Java技术盛宴
  6. android:layout_gravity 和 android:grav
  7. TS3.0 引入 opengl es 1.x, opengl es 2.
  8. Android的消息机制,用Android线程…
  9. 【转】有关Android线程的学习
  10. Android常用复杂控件使用(三)--Fragment