安卓蓝牙通知
我正在 android 中开发蓝牙应用程序。一旦两个设备之间建立连接,我就会在两个设备之间发送数据。我的问题是,每当任一设备蓝牙关闭时,我希望将其通知给其他设备,并希望打印一条 toast 消息,指出“其他设备蓝牙已关闭”。如何做到这一点?
谢谢
I am developing an Bluetooth application in android.Once connection is made between two devices i am sending data between two devices. My problem is whenever either of the devices Bluetooth is turned off i want that to be notified to other device and want to print a toast message stating that "Other device Bluetooth is turned off".How to do this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以监视蓝牙连接(侦听广播操作:ACTION_ACL_DISCONNECTED)并通知连接已断开。连接断开并不一定意味着它已关闭,但这肯定是一个副作用。
You can monitor the bluetooth connection (listening to Broadcast action : ACTION_ACL_DISCONNECTED) and notify that the connection has gone. Dropping of connection does not necessarily mean it is powered off , but it is surely a side-effect.
以下链接可能对您有用
The following link can be useful to you