华为 M5 Proairpods支持蓝牙5.00吗

如果各位觉得有用,转载+个出处。
现如今安卓的低功耗蓝牙应用十分普遍了,智能手环、手表遍地都是,基本都是利用BLE通信来交互数据。BLE基本在安卓、IOS两大终端设备上都有很好支持,所以有很好发展前景。
现市面上各种手环、手表的智能设备中基本都充当"从设备"这样的角色,基本由智能设备完成蓝牙广播,由手机进行连接,然后交互数据。
根据上述方式的应用在安卓4.3、IOS 7.0的版本上就得到了支持,应用也比较广泛,园里应该有很多相关实现,大家可以自己找找,如果不愿意找,抽空再写一篇。
今天主要是为了说在安卓5.0时升级了广播相关API,园里也有一些说明,但之所以还写这篇是因为数据交换的提及很少。
既然将手机要做广播了,那么实质手机就变成手环、手表的角色,一个从设备了。
如果你愿意,可以拿另一台手机做个主设备,这样他们就可以交流了。
好了,我们进入代码正题吧...
首先应用权限设置。在AndroidManifest.xml中还是要加入BLE控制权限,不然异常一定与你为伍。
&uses-permission android:name="android.permission.BLUETOOTH" /&
&uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /&
&接着我们上套路了,判断手机是否支持BLE以及是否支持BLE从设备。
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
showToast("该设备不支持蓝牙低功耗通讯");
this.finish();
bluetoothManager = (BluetoothManager) getSystemService(BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
if (bluetoothAdapter == null) {
showToast("该设备不支持蓝牙低功耗通讯");
this.finish();
bluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
if (bluetoothLeAdvertiser == null) {
showToast("该设备不支持蓝牙低功耗从设备通讯");
this.finish();
我建议你先拿你调试设备试试,大多数同学走到这里都绝望了。你问我为啥?你试试就知道了。
如果你一脸what???的话,那恭喜你,你的调试设备是被选中的孩子,让我们继续乘风破浪吧。顺便在评论里告诉我下你用啥设备哦。
这时候我们开启广播的旋风吧。
//广播设置
AdvertiseSettings.Builder settingBuilder = new AdvertiseSettings.Builder();
settingBuilder.setConnectable(true);
settingBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
settingBuilder.setTimeout(0); //我填过别的,但是不能广播。后来我就坚定的0了
settingBuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
AdvertiseSettings settings = settingBuilder.build();
//广播参数
AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder();
bluetoothAdapter.setName("H8-BlePpl"); //你想叫啥名字,你愿意就好
dataBuilder.setIncludeDeviceName(true);
dataBuilder.setIncludeTxPowerLevel(true);
dataBuilder.addServiceUuid(ParcelUuid.fromString(Const.UUID_SERVICE)); //可自定义UUID,看看官方有没有定义哦
AdvertiseData data = dataBuilder.build();
bluetoothLeAdvertiser.startAdvertising(settings, data, advertiseCallback);
然后你的小手机就开始广播了,说大家来连我啊连我啊。别总搜地址,貌似地址动态会变的,还是用名儿吧毕竟你起了啊。
我之前傻傻的查了手机蓝牙MAC地址,后来发现不是广播的那个...
广播回调我干了点新增服务的活儿,不干你拿啥通信来。
private AdvertiseCallback advertiseCallback = new AdvertiseCallback() {
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
super.onStartSuccess(settingsInEffect);
runOnUiThread(new Runnable() {
public void run() {
showInfo("1.1 AdvertiseCallback-onStartSuccess");
bluetoothGattServer = bluetoothManager.openGattServer(getApplicationContext(),
bluetoothGattServerCallback);
BluetoothGattService service = new BluetoothGattService(UUID.fromString(Const.UUID_SERVICE),
BluetoothGattService.SERVICE_TYPE_PRIMARY);
UUID UUID_CHARREAD = UUID.fromString(Const.UUID_CHARACTERISTIC);
//特征值读写设置
BluetoothGattCharacteristic characteristicWrite = new BluetoothGattCharacteristic(UUID_CHARREAD,
BluetoothGattCharacteristic.PROPERTY_WRITE |
BluetoothGattCharacteristic.PROPERTY_READ |
BluetoothGattCharacteristic.PROPERTY_NOTIFY,
BluetoothGattCharacteristic.PERMISSION_WRITE);
UUID UUID_DESCRIPTOR = UUID.fromString(Const.UUID_CHARACTERISTIC_CONFIG);
BluetoothGattDescriptor descriptor = new BluetoothGattDescriptor(UUID_DESCRIPTOR, BluetoothGattCharacteristic.PERMISSION_WRITE);
characteristicWrite.addDescriptor(descriptor);
service.addCharacteristic(characteristicWrite);
bluetoothGattServer.addService(service);
runOnUiThread(new Runnable() {
public void run() {
showInfo("1.2. Service Builded ok");
当你收到广播成功回调后,来吧,特征值啊~~反正要通信呐~~
被你发现了我偷懒读写特征值用了一个,其实你愿意用两个就用两个吧。
我用的NOTIFICATION方式做主设备的读取,你也可用INDICATION方式做。
服务建立完成后,也会收到通知。BLE嘛~~都是异步回调~~我是习惯了!
private BluetoothGattServerCallback bluetoothGattServerCallback = new BluetoothGattServerCallback() {
public void onServiceAdded(int status, BluetoothGattService service) {
super.onServiceAdded(status, service);
final String info = service.getUuid().toString();
runOnUiThread(new Runnable() {
public void run() {
showInfo("1.3 BluetoothGattServerCallback-onServiceAdded " + info);
public void onConnectionStateChange(BluetoothDevice device, int status, int newState) {
super.onConnectionStateChange(device, status, newState);
final String info = device.getAddress() + "|" + status + "-&" + newS
runOnUiThread(new Runnable() {
public void run() {
showInfo("1.4 onConnectionStateChange " + info);
public void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset,
BluetoothGattCharacteristic characteristic) {
super.onCharacteristicReadRequest(device, requestId, offset, characteristic);
final String deviceInfo = "Address:" + device.getAddress();
final String info = "Request:" + requestId + "|Offset:" + offset + "|characteristic:" + characteristic.getUuid() + "|Value:" +
Util.bytes2HexString(characteristic.getValue());
runOnUiThread(new Runnable() {
public void run() {
showInfo("=============================================");
showInfo("设备信息 " + deviceInfo);
showInfo("数据信息 " + info);
showInfo("=========onCharacteristicReadRequest=========");
bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, characteristic.getValue());
public void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
super.onCharacteristicWriteRequest(device, requestId, characteristic,
preparedWrite, responseNeeded, offset, value);
final String deviceInfo = "Name:" + device.getAddress() + "|Address:" + device.getAddress();
final String info = "Request:" + requestId + "|Offset:" + offset + "|characteristic:" + characteristic.getUuid() + "|Value:" + Util.bytes2HexString(value);
bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
//TODO:你做数据处理
runOnUiThread(new Runnable() {
public void run() {
showInfo("=============================================");
showInfo("设备信息 " + deviceInfo);
showInfo("数据信息 " + info);
showInfo("=========onCharacteristicWriteRequest=========");
public void onNotificationSent(BluetoothDevice device, int status) {
super.onNotificationSent(device, status);
final String info = "Address:" + device.getAddress() + "|status:" +
runOnUiThread(new Runnable() {
public void run() {
showInfo("onNotificationSent " + info);
public void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value) {
final String deviceInfo = "Name:" + device.getAddress() + "|Address:" + device.getAddress();
final String info = "Request:" + requestId + "|Offset:" + offset + "|characteristic:" + descriptor.getUuid() + "|Value:" + Util.bytes2HexString(value);
runOnUiThread(new Runnable() {
public void run() {
showInfo("=============================================");
showInfo("设备信息 " + deviceInfo);
showInfo("数据信息 " + info);
showInfo("=========onDescriptorWriteRequest=========");
// 告诉连接设备做好了
bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, value);
public void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor) {
super.onDescriptorReadRequest(device, requestId, offset, descriptor);
final String deviceInfo = "Name:" + device.getAddress() + "|Address:" + device.getAddress();
final String info = "Request:" + requestId + "|Offset:" + offset + "|characteristic:" + descriptor.getUuid();
runOnUiThread(new Runnable() {
public void run() {
showInfo("=============================================");
showInfo("设备信息 " + deviceInfo);
showInfo("数据信息 " + info);
showInfo("=========onDescriptorReadRequest=========");
// 告诉连接设备做好了
bluetoothGattServer.sendResponse(device, requestId, BluetoothGatt.GATT_SUCCESS, offset, null);
基本上从设备就做完了。
调试的时候你用主设备查服务列表可能查不到你的UUID_SERVICE,但是别慌,你getServcie(UUID_SERVICE)试试,说不定就柳暗花明了。
还有就是我拿的华为Honor 8做的调试机子,其他还有啥型号请各位分享下。姑娘我跪谢啦~~
阅读(...) 评论()平板/笔记本
终端云服务专区
【EMUI5.0教程】还在用蓝牙?不会用Huawei Share你就out啦!
&花粉版主&
来自:浏览器
本帖最后由 心想是橙 于
21:47 编辑
105216lztavd4zuapinnin.jpg (60.67 KB, 下载次数: 1)
21:36 上传
当你想把手机里拍摄的旅行精彩照片,或者一首珍藏的无损品质音乐分享给身边的小伙伴时,你是不是总会苦恼:用蓝牙传输吧,传输速度太慢;用WLAN直连传输吧,操作又太麻烦?此时,你一定希望能有一个操作又简单,传输速度又快的方法吧!!!
今天,教你get一个新技巧,使用华为 的Huawei Share,你只需要简单的三步操作,就可以快速分享文件(比如:图片、视频、音频等)给小伙伴。
1. 首先当然是要打开Huawei Share啦!
在小伙伴的手机上,从状态栏处向下滑动,打开通知面板。然后点击【Huawei Share & 允许】。
说明:小伙伴的手机要一直处于亮屏状态,并且你和小伙伴的距离要在蓝牙的有效范围(10米)内。
2. 在你的手机上,选择你想分享的文件,点击【分享】,然后点击【Huawei Share】区域。你的手机会发现附近的设备。
说明:如果你的手机 WLAN 和蓝牙开关都已开启,点击【分享】后,你的手机会自动发现附近的设备。
3.选择小伙伴的手机名称。待小伙伴的手机弹出提示框后,点击【接受】。然后就会看到文件“嗖嗖”地发送给小伙伴了。
说明:接收到的文件默认存储在文件管理的 Huawei Share 文件夹里。
【科普:Huawei Share比蓝牙和WLAN直连还要快速方便,原理是啥呢?】
游客,如果您要查看本帖隐藏内容请
当然,要想获得这个体验,前提条件是:你和小伙伴的华为手机都支持 Huawei Share,也就是说,都要升级到最新的5.0哦。
错过了升级机会的小伙伴也不要着急哦,下次还会继续开放申请渠道,具体请留意里的置顶公告哈~
width:100%">
&花粉版主&
来自:浏览器
沙发是我的~欢迎反馈问题哦
width:100%">
&独步江湖&
来自:华为Mate8 NXT-AL10
width:100%">
&花粉版主&
来自:浏览器
width:100%">
&登堂入室&
来自:HUAWEI NXT-TL00
nnjjjjjjnnnnjjj
width:100%">
&登堂入室&
来自:HUAWEI NXT-TL00
nnjjjjjjnnnnjjj
width:100%">
&渐入佳境&
来自:华为Mate8 NXT-AL10
快牙比这个好用吧。
width:100%">
&渐入佳境&
来自:华为Mate8 NXT-AL10
width:100%">
&登堂入室&
来自:浏览器
适用范围太窄
width:100%">
&炉火纯青&
来自:华为Mate8 NXT-AL10
学习下,多谢分享
width:100%">
关注华为花粉俱乐部微信公众平台——“华为花粉俱乐部”
好基友勋章
花粉好机友,注册时间大于99天
1000万花粉
纪念花粉俱乐部注册花粉数超过1000万
在职斑竹的身份勋章,感谢斑竹的辛勤劳动
我家住在黄土高坡家有小女【夜赏艺术中心】【花粉随手拍】雪中小景古塔四季飞 雪 阅 江 楼
花粉客户端
Make it Possible
Make your device special
华为云服务
Huawei cloud services
音乐播放器
Huawei Music
Huawei Vmall
关注花粉俱乐部
举报邮箱:
|关注花粉俱乐部:
Copyright (C)
华为软件技术有限公司 版权所有 保留一切权利红米手机 &
骨灰级手机控
扫码下载App一键签到 升级加速
小米6的蓝牙5.0支持什么编码AAC?
扫一扫!手机看帖更爽
SBC :这是最早的蓝牙音频传输编码,音质也是最差的,但兼容性最好,随便一部手机的蓝牙都支持SBC。  ◆AAC :音质比SBC更好,iPhone就会使用这种蓝牙编码,也被其他手机广泛支持。如果手机播放的是AAC音频文件,那么使用AAC蓝牙编码传输可以少一个编码转换的步骤,音质更加保真。  ◆aptX :aptX是更高一档的蓝牙音频编码,其中aptX-HD可以做到接近无损音质(但还是有损)。目前比较高档的手机会支持这个编码,但iPhone 7是不支持的,因为这个编码标准背后是高通。iPhone 7使用了专门的W1芯片负责处理蓝牙音频,也许配合Airpods使用了私有的蓝牙编码传输。?aptX-HD背后是高通  ◆LDAC。索尼目前力推的蓝牙音频编码,最大的卖点就是能够做到Hi-Res无损音频传输,音质是最好的!但是目前除了索尼自己的手机和蓝牙耳机,并没有什么其他设备支持这种编码。
扫描二维码,手机查看本帖
: 小米6超级米粉Q总群
超多福利,感谢您的加盟
已有1人评分
一起见证小米6的到来,加米粉Q总群
快满群,速度加
总评分: 经验 +1
盒子用户600 发表于
11:59:32我就想知道是不是又在这方面省钱了,毕竟aptx是20007年的技术了吗,连HTC早年的机器还有黑莓都支持,米6取消了耳机口,是不是把蓝牙的音质稍微提升下哈国内大环境是这样,能省就省。大品牌里面除了OV和魅族的中高端机之外,其他国产品牌都不支持aptx,华为是所有手机包括mate9 pro都不支持。不过,听说一加三的最新固件加入了aptx。
通过不同渠道一直在问小米6是否支持aptx,从来没有得到过肯定的回复,连官方客服都不知道是否支持aptx。已经抢到小米6的人之中难道没有一个人用aptx蓝牙耳机的?
大家好,我搞到小米6的F码,谁要了? 谁要加我扣号我有64G版本或者128G版本
米化工 发表于
14:00:21这和米6有关系吗有关系啊,我想买米6,又有听歌的需求,打算买个蓝牙接收器插耳机听歌,手机当发射端,当然希望米6能把蓝牙音质提升的不能低于其他品牌的旗舰机
·来自小米手机4c
这和米6有关系吗
·来自小米手机5
楼主专业,为楼主点赞,米粉就应该多发一些有营养的帖。
涨知识了啊
我就想知道是不是又在这方面省钱了,毕竟aptx是20007年的技术了吗,连HTC早年的机器还有黑莓都支持,米6取消了耳机口,是不是把蓝牙的音质稍微提升下哈
京ICP证110507号 京ICP备号当前位置 & &
& 麒麟960+安卓8.0!华为MediaPad M5曝光
麒麟960+安卓8.0!华为MediaPad M5曝光
00:10:58&&作者:振亭
编辑:振亭 &&)
让小伙伴们也看看:
阅读更多:
好文共享:
文章观点支持
文章价值打分
当前文章打分0 分,共有0人打分
[12-18][12-18][12-18][12-18][12-18][12-18][12-18][12-18][12-18][12-17]
登录驱动之家
没有帐号?
用合作网站帐户直接登录

我要回帖

更多关于 airpods支持蓝牙5.0 的文章

 

随机推荐