正如我从http://code.google.com/p/android/issues/detail?id=6348#makechanges上的讨论中看到的,我们可以让安卓蓝牙无限制地被发现,我看到蜂巢3.1现在可以公开使用了,有谁能解释一下使用蜂巢3.1开发环境我如何才能让蓝牙不断被发现?我浏览了文档,但找不到任何适合我的解决方案的方法。。提前谢谢。。
发布于 2011-06-21 22:45:00
我相信在您调用BluetoothAdapter.cancelDiscovery()之前,BluetoothAdapter.startDiscovery()会一直保持蓝牙适配器的可发现性。
发布于 2019-06-11 14:31:31
You can try this:
try {
Method bluetoothDeviceVisibility;
bluetoothDeviceVisibility = mBluetoothAdapter.getClass().getMethod("setScanMode", int.class, int.class);
bluetoothDeviceVisibility.invoke(mBluetoothAdapter, BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE, 0);
} catch (Exception e) {
e.printStackTrace();
}发布于 2014-08-04 17:50:27
遵循意图应该可以做到这一点。
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION,discoverableIntent =新的Intent 0);startActivity(discoverableIntent);
“你可以通过额外添加EXTRA_DISCOVERABLE_DURATION Intent来定义不同的持续时间。应用程序可以设置的最长持续时间为3600秒,值为0表示设备始终可被发现。”
来源:http://developer.android.com/guide/topics/connectivity/bluetooth.html
https://stackoverflow.com/questions/6427146
复制相似问题