I finally figured this problem out. The device I am using is a Samsung Galaxy S4 and the actual problem (thanks Wibble for guidance in your answer, but you are slightly off in your conclusion) appears to be a threading issue.

In Wibble's answer, he stated that adding a button to connect fixed his issue. I started wondering why that matters, and I also can connect and disconnect fine during an entire session without a GUI button using background worker threads. As soon as I force close my application, restart it, and try to connect, I start getting the error "Failed to register callback." and nothing works any more. I almost pulled my hair out over this one :)

See my post in Samsung's forums for more detail on my exact issues.

Solution: To get around this issue, just make sure you run any BLE interaction code (device#connectGatt, connect, disconnect, etc) code in the UIThread (with a handler, local service, or Activity#runOnUiThread). Follow this rule of thumb and you will hopefully avoid this dreadful problem.

Deep in our library, I only had access to the application context. You can create a handler from a context that will post to the main thread by using new Handler(ctx.getMainLooper());

If you face other connection problems, deploy the sample app in samples\android-18\legacy\BluetoothLeGatt and see if that application works. That was kind of my baseline for realizing BLE does actually work with my peripheral, and gave me hope that if I dug enough in our library I would eventually find the answer.

EDIT: I did not see this 'Failed to register callback' issue on the Nexus 4, Nexus 5, or Nexus 7 2013 when using background threads to perform BLE operations. It may just be an issue in Samsungs 4.3 implementation.

http://stackoverflow.com/questions/20069507/solved-gatt-callback-fails-to-register

SOLVED: GATT callback fails to register的更多相关文章

  1. 【solved】must have one register DataBase alias named `default`

    beego在初始化MySQL数据库时报错处理 1.报错提示: ... [ORM]2019/10/11 08:42:52 register db Ping `default`, dial tcp 192 ...

  2. laravel5.5用户认证源码分析

    目录 1. 生成相关文件和配置 2. 分析路由文件 3. 以登陆开始为例,分析auth到底是怎么工作的 3.1 分析登录文件 3.2 分析门面Auth. 1. 生成相关文件和配置 快速生成命令 php ...

  3. 利用WCF双工模式实现即时通讯

    概述 WCF陆陆续续也用过多次,但每次都是浅尝辄止,以将够解决问题为王道,这几天稍闲,特寻了些资料看,昨晚尝试使用WCF的双工模式实现了一个简单的即时通讯程序,通过服务端转发实现客户端之间的通讯.这只 ...

  4. CREATE FILE encountered operating system error 5(Access is denied.)

    这篇博文主要演示"CREATE FILE encountered operating system error 5(Access is denied.)"错误如出现的原因(当然只是 ...

  5. Await, and UI, and deadlocks! Oh my!

    It’s been awesome seeing the level of interest developers have had for the Async CTP and how much us ...

  6. 彻底理解Toast原理和解决小米MIUI系统上没法弹Toast的问题

    1.Toast的基本使用 Toast在Android中属于系统消息通知,用来提示用户完成了什么操作.或者给用户一个必要的提醒.Toast的官方定义是这样的: A toast provides simp ...

  7. phalcon: queueing使用心得,需要安装相应的软体

    http://flyhighest.com/archives/50 原本没有用过phalcon的消息队列,本来以为很简单,结果搞了半天,把步骤记录一下. phalcon的官网上没有说需要安装beans ...

  8. Platform Invoke

    PInvoke 允许managed code 来调用在DLL中实施的unmanged function. Platform invoke relies on metadata to locate ex ...

  9. Android4.0窗口机制和创建过程分析

    一  前言 在谈到这个话题的时候,脑海里面千头万绪,因为它涉及到了方方面面的知识… 比如Activity管理,窗口添加,Token权限验证等等… 既然这么复杂,那么我们就复杂的问题简单化,可以分成下面 ...

随机推荐

  1. OpenShare文档中心

    文档是企业重要的智力资产.在企业中,文档一般都以电子文档的形式存在,比如微软.doc格式,xls格式,ppt格式,pdf格式,纯文本.txt格式等:从内容上,可能是商务合同.会议记录.产品手册.客户资 ...

  2. css3 transfrom使用以及其martix(矩阵)属性与其它属性的关系

    写法 其属性martix与skew .scale .translate之间的关系   兼容性 :       IE9+ : -ms-transform :  IE9只支持2D转换       fire ...

  3. php学习笔记5--php中的可变变量,可变函数及匿名函数

    可变变量指的是:将一个变量的值再次当做一个变量名从而得到另外一个变量的值.如:$name = 'dqrcsc';$myname = 'name'; //$myname的值碰巧是另一个变量的变量名ech ...

  4. 1 ubuntu下装setuptools

    setuptools可以让程序员更方便的创建和发布 Python 包,特别是那些对其它包具有依赖性的状况,分享以下我在ubuntu下装setuptools的过程 系统:ubuntu 语言:python ...

  5. asp.net在网页上显示数据库中的数据

    第一步: 第二步: 第三步: 第四步:在网页代码中写显示格式代码,如下 <asp:SqlDataSource ID="SqlDataSource1" runat=" ...

  6. 防止服务器被暴力破解使用DenyHosts

    公司有台服务器被坏人盯上了,通过日志可以看到一直在做暴力破解ssh. 防止服务器被暴力破解使用DenyHosts 参考链接: 防止ssh破解,Ubuntu安装denyhosts的一些问题 防止你的ss ...

  7. C# lock用法

    当我们使用线程的时候,效率最高的方式当然是异步,即各个线程同时运行,其间不相互依赖和等待.但当不同的线程都需要访问某个资源的时候,就需要同步机制了,也就是说当对同一个资源进行读写的时候,我们要使该资源 ...

  8. 20140122-Application19事件

  9. websphere中由于实际应用没有卸载干净,导致安装不了。以下是完全卸载应用程序的方法

     出现此问题的原因之一:操作界面上没有卸载完成.进行一下操作:1.删除 $WAS_HOME/profiles/AppSrv01/config/cells/...cell/applications下对应 ...

  10. Python的 is 运算符

    1. is运算符判断的是同一性而不是相等性. #x和y都绑定到同一个列表,而z被绑定在另外一个具有相同数值和顺序的列表上 x = y = [1, 2, 3] z = [1, 2, 3] x == y ...