android BluetoothLE 多个 setCharacteristicNotification writeCharacteristic 失效
如果在搜索完服务后,执行多个 setCharacteristicNotification 或 writeCharacteristic 操作,某些操作可能会无效。需要在中间等待一些时间,真是一个大坑!
new Thread(new Runnable() {
@Override
public void run() {
try {
for (BluetoothGattService gattService : mBluetoothLeService.getSupportedGattServices()) {
List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
if (gattCharacteristic.getUuid().toString().equals("0000XXXX-0000-XXXX-XXXX-00XXXXXXXXXX")) {
Thread.sleep(150);
mgattCharacteristic = gattCharacteristic;
byte[] value = new byte[7];
/*
value = ......
*/
mgattCharacteristic.setValue(value);
mBluetoothLeService.writeCharacteristic(mgattCharacteristic);
}
if (gattCharacteristic.getUuid().toString().equals("0000XXXX-0000-XXXX-XXXX-00XXXXXXXXXX")){
Thread.sleep(150);
mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
android BluetoothLE 多个 setCharacteristicNotification writeCharacteristic 失效的更多相关文章
- android开发 eclipse alt+”/”自动提示失效
http://blog.unvs.cn/archives/android-eclipse-alt.html 按照其中的第一条+第二条 处理 注意:abcd要替换为 abcdefghijklmnopqr ...
- Android bluetooth low energy (ble) writeCharacteristic delay callback
I am implementing a application on Android using BLE Api (SDK 18), and I have a issue that the trans ...
- Android ListView item 点击事件失效问题的解决
关于ListView点击无效,item无法相应点击事件的问题,网上有很多, 大致可分为俩种情况, 一种是 item中存在 ImageButton 等可以点击的组件,这会抢先获得ListView的焦点. ...
- android apk打包之后js调用失效的解决办法
现在android下应用开发的界面用html5+css3写,交互用javascript和java沟通,但是用上混淆后发现javascript调用java类定义的方法老说找不到这个方法.一番折腾后发现是 ...
- 解决SpannableString在Android组件间传递时显示失效的问题
问题:在A activity中传递一个SpannableString到B activity中,并最终传递到B activity中的TextView中,但是没有展示出Span效果. 解决:阅读TextV ...
- session图片验证码,页面和请求是两个地址。android手机好用,iphone 失效。
问题描述:之前在H5页面用session做了一个验证码.安卓手机好使.但是到苹果就不好使了(页面访问是一个域名地址,ajax请求是用另外的一个ip地址). 详细说明: 验证码请求后台图片正常显示,an ...
- android WebView中js的alert()失效
WebView的设置代码 wv = (WebView) findViewById(R.id.webView1); wv.getSettings().setJavaScriptEnabled(true) ...
- [转]android中listview点击事件失效
首先说明一下我想实现的功能: 点击某个item之后,让其颜色发生变化.如果变化网上有很多例子,我就不班门弄斧了.Listview之所以点击没有反应是因为上图中绿色部分(自己定义的一个继承BaseAda ...
- android中listview点击事件失效的灵异事件
首先说明一下我想实现的功能: 点击某个item之后,让其颜色发生变化.如果变化网上有很多例子,我就不班门弄斧了.Listview之所以点击没有反应是因为上图中绿色部分(自己定义的一个继承BaseAda ...
随机推荐
- c代码读取目录信息
#include <stdio.h> #include <sys/types.h> #include <dirent.h> int main(void) { DIR ...
- SQL 字符串处理大全
select语句中只能使用sql函数对字段进行操作(链接sql server),select 字段1 from 表1 where 字段1.IndexOf("云")=1;这条语句不对 ...
- 【转】Mac系统中安装homebrew(类似redhat|Centos中的yum;类似Ubuntu中的apt-get)
Homebrew,Homebrew简称brew,是Mac OSX上的软件包管理工具,能在Mac中方便的安装软件或者卸载软件,可以说Homebrew就是mac下的apt-get.yum神器 Homebr ...
- hbase hmaster故障分析及解决方案:Timedout 300000ms waiting for namespace table to be assigned
最近生产环境hbase集群出现停掉集群之后hmaster无法启动现象,master日志报异常:Timedout 300000ms waiting for namespace table to be a ...
- poi批量导入excel文件
package com.practice.util; import java.io.File; import java.io.FileInputStream; import java.io.FileN ...
- MIME Sniffing
Abstract: The web.config file does not include the required header to mitigate MIME sniffing attacks ...
- UIViewController中addChildViewController的作用
当在一个ViewController中添加一个子ViewController时,UI部分可以直接通过addSubView的方法添加,例如: 在一个ViewControllerA中添加ViewContr ...
- python基础知识4——collection类——计数器,有序字典,默认字典,可命名元组,双向队列
1.计数器(counter) Counter是对字典类型的补充,用于追踪值的出现次数. ps:具备字典的所有功能 + 自己的功能 Counter 我们从中挑选一些相对常用的方法来举例: 在上面的例子 ...
- 如何理解JS回调函数
1.回调函数英文解释: A callback is a function that is passed as an argument to another function and is execut ...
- Perl语言
Perl是高级.通用.直译式.动态的程序语言家族.最初设计者拉里·沃尔(Larry Wall)为了让在UNIX上进行报表处理的工作变得更方便,决定开发一个通用的脚本语言,而在1987年12月18日发表 ...