您的位置:首页 > 产品设计 > UI/UE

安卓程序代写 网上程序代写[原]Android之Bluetooth编程

2013-10-21 10:58 1176 查看
ViewGroup 相关资料 :

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

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

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

/article/2473969.html

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

/article/4997749.html

蓝牙开发指南 :

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

蓝牙编程 :

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

/article/1414164.html BluetoothAdapter类简介

/article/4602643.html


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

http://www.wuphone.com/579.html BluetoothAdapter蓝牙

/article/4602644.html


BluetoothDevice[蓝牙]

/article/2735262.html


android蓝牙开发——基本概念

/article/1363074.html 十三篇之探秘蓝牙隐藏API

/article/4707620.html 隐藏api介绍

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

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);

/article/3505036.html


如何实现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
plaincopy

<manifest ... >

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

...

</manifest>

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

作者:han1202012 发表于2013-10-21 10:57:44 原文链接

阅读:133 评论:0 查看评论
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: