开发者

Android Application Bluetooth visibility duration

Is there a way to let my application be discoverable for a time the app is running? I tried to do this with

Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.开发者_运维百科putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 0);
startActivityForResult(discoverableIntent, DISC_DURATION);

as shown on Android Developers, but the Duration of 0 doesn't work so the default value 120 is set. Is there a way to set it as visible all the time?


there is no mean for keep Bluetooth discoverable all time. At the time when you want to find some new devices or other devices can find your device you have to make it discoverable. After that your device will interchange a shared MAC id and will make a paired.

Performing device discovery is a heavy procedure for the Bluetooth adapter and will consume a lot of its resources. Once you have found a device to connect, be certain that you always stop discovery with cancelDiscovery() before attempting a connection. Also, if you already hold a connection with a device, then performing discovery can significantly reduce the bandwidth available for the connection, so you should not perform discovery while connected.

for more info see this

http://developer.android.com/guide/topics/wireless/bluetooth.html#DiscoveringDevices


There is no way for you to set bluetooth to be continuously discoverable on any 2.* version of Android; see this bug report. It seems like the limitation has been removed in 3.* versions, but I haven't seen any confirmation of this.


I come to the conclusion on three devices I have.

ANDROID v 4.3 and higher : EXTRA_DISCOVERABLE_DURATION 0 works no limit ANDROIND v 4.1 : EXTRA_DISCOVERABLE_DURATION 0 is max 1 hour. Have to change manually to no limit in parameters.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜