想要一个Android的蓝牙是始终可见,直至应用程序运行? [英] Want a Android bluetooth to be always visible until app running?

查看:166
本文介绍了想要一个Android的蓝牙是始终可见,直至应用程序运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要那,直到应用程序正在运行我的蓝牙可见。像无限的时间。我会关掉它时,林用它做。

I want that my bluetooth to be visible until the app is running. Like for infinite time. I will turn it off when Im done with it.

我不希望它要求用户的能见度持续时间在下面的方法

I don't want it to ask user for duration of visibility as in following method

  Intent discoverableIntent = new
  Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
  discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,300);
  startActivity(discoverableIntent);

请帮忙!

推荐答案

简短的回答是,你不能;看到这个错误报告。相信我,我是生气关于这个问题,你是;它使蓝牙点对点网络非常困难。还有一些对线程的一些建议,希望限制在了蜂窝,或许将使其成为冰淇淋三明治。目前,有没有办法解决它,总之安装自定义ROM的。

The short answer is that you can't; see this bug report. Trust me, I'm as annoyed about this as you are; it makes ad-hoc networking on Bluetooth very difficult. There are some suggestions on that thread that the limitation is gone in Honeycomb and perhaps will make it into Ice Cream Sandwich. For the moment, there is no way around it, short of installing a custom ROM.

随着中说,有一些解决方法。由于Android要求任何蓝牙接口(服务器的的客户端)可以发送数据,已配对您的应用程序可以简单地尝试连接设备之前配对。当然,大部分时间的连接将失败,但是如果配对的设备是在范围内的连接会发生。我已经在我的应用程序实现这一点,它似乎工作。我不知道这将如何影响电池的寿命,但有足够的时间扫描之间,你应该会好起来的。

With that said, there are some workarounds. Since Android requires pairing before any Bluetooth socket (server or client) can send data, your app can simply try and connect to already paired devices. Sure, most of the time the connection will fail, but if a paired device is in range the connection will happen. I've implemented this in an application of mine and it seems to work. I'm not sure how this affects battery life, but with enough time between scans you ought to be okay.

我希望的Andr​​oid未来的版本将不会有这种不必要的限制,因为它prevents一些潜在的有趣的特设网络应用程序。

I'm hoping that future versions of Android won't have this unnecessary limitation as it prevents some potentially interesting ad-hoc networking applications.

这篇关于想要一个Android的蓝牙是始终可见,直至应用程序运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆