- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我在使用 startDiscovery() 时遇到问题。这是问题所在,我已经像这样向我的 BroadcastReceiver 注册了以下 Intents:
IntentFilter filterFound = new IntentFilter(BluetoothDevice.ACTION_FOUND);
IntentFilter filterStart = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_STARTED);
IntentFilter filterStop = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
registerReceiver(myReceiver, filterFound);
registerReceiver(myReceiver, filterStart);
registerReceiver(myReceiver, filterStop);
这是我的广播接收器:
private BroadcastReceiver myReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive (myReceiver)");
String action = intent.getAction();
// When discovery finds a device
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Add the name and address to an array adapter to show in a ListView
Log.d(TAG,device.getName() + " " + device.getAddress());
deviceListAdapter.add(device.getName() + "\n" + device.getAddress());
}
if (BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals(action)) {
Log.d(TAG, "Started discovery");
}
if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
Log.d(TAG, "Finished discovery");
}
}
};
当我在我的蓝牙适配器(蓝牙存在并启用)上调用 startDiscovery 时,没有任何反应,我在 logcat 中也看不到任何关于 BroadcastReceiver 的信息。
您是否遇到过此类问题?任何帮助表示赞赏:)
谢谢
最佳答案
确保您对 AndroidManifest.xml 拥有适当的权限.特别是,要执行发现,您需要 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
.
关于android - Android 上的蓝牙 : startDiscovery doesn't work and I have bluetooth enabled,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5903671/
import android.app.Service; import android.bluetooth.BluetoothAdapter; import android.bluetooth.Blue
目标:构建一个 Android 应用程序,用于发现范围内的 BT 设备的名称和地址,并将它们的值提交给网络服务。 BT 设备以前没有绑定(bind)到主机设备,我只是想边走边轮询所有内容。 我做了什么
我试图发现附近的蓝牙设备,但 startDiscovery() 总是返回 false,就好像它不工作一样。因此它无法找到设备。 我看到除了蓝牙和 Bluetooth_Admin 之外,我必须包含 Co
我正在开发一款搜索可发现设备并将其显示为按钮的应用。当调用 startDiscovery() 时,根据我目前使用 BroadcastReceiver 和 ACTION_DISCOVERY_FINISH
我是 android 新手,我正在制作一个具有蓝牙功能的应用程序。我可以设置蓝牙适配器,获取我自己的设备信息,但我无法使用 startdiscovery 来发现蓝牙设备。当我开始扫描时,它什么也不做。
我遇到了一个问题。我尝试了 Stack Overflow 和其他网站的一些提示。 我想编写一个应用程序,它搜索周围的所有蓝牙设备,如果找到匹配的设备(MAC地址作为引用),应用程序将开始连接。 因此,
我正在尝试使用 dbus-send 与 Bluez 5.44 进行交互命令行工具。我似乎无法让它正确地开始发现,尽管当我使用 bluetoothctl 的 scan on 和 scan off 命令时
我正在尝试使用 dbus-send 与 Bluez 5.44 进行交互命令行工具。我似乎无法让它正确地开始发现,尽管当我使用 bluetoothctl 的 scan on 和 scan off 命令时
我正在尝试编写一些代码,可以扫描附近的蓝牙设备。我觉得理解起来有点复杂,所以我寻求帮助。 首先,我将解释我的场景。我从 bluez 适配器 API (https://git.kernel.org/pu
该应用程序面向 22 位用户,最低版本为 18,并且可以在 Lollipop 上正常运行。启动 Marshmallow 应用程序需要 BLE 的“精细”和“粗略”权限。我已经添加了它们,但没有触发回调
我在bluez-5.36 库 中搜索了StartDiscovery() 方法,但找不到。 有人能告诉我这个方法是在哪里实现的吗? 它在“bluez-5.36/doc/”目录的“adapter-api.
我在使用 startDiscovery() 时遇到问题。这是问题所在,我已经像这样向我的 BroadcastReceiver 注册了以下 Intents: IntentFilter filterFou
我有一个使用蓝牙并连接到设备的应用程序,找不到任何使用 BluetoothAdapter.getDefaultAdapter().startDiscovery() 的设备;它在发现之前运行良好。也试过
本文整理了Java中com.zsmartsystems.zigbee.app.discovery.ZigBeeDiscoveryExtension.startDiscovery()方法的一些代码示例,
本文整理了Java中com.zsmartsystems.zigbee.app.discovery.ZigBeeNodeServiceDiscoverer.startDiscovery()方法的一些代码
我是一名优秀的程序员,十分优秀!