相关疑难解决方法(0)

556
推荐指数
8
解决办法
32万
查看次数

动态注册广播接收器不起作用--BluetoothDevice.ACTION_FOUND

Logclass跟踪运行时显示onReceive()方法没有调用,为什么?

动态注册广播接收器

 private void discoverDevices () {
    Log.e("MOHAB","BEFORE ON RECEIVE");

     mReceiver = new BroadcastReceiver() {
        public void onReceive(Context context, Intent intent) {
            Log.e("MOHAB","ON RECEIVE");
            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
                Bluetooth b = new Bluetooth(device.getName(),device.getAddress());
                list.add(b);
            }
        }
    };
    Log.e("MOHAB","create intentFilter");
    // …
Run Code Online (Sandbox Code Playgroud)

android android-broadcastreceiver

13
推荐指数
4
解决办法
1万
查看次数

由于棉花糖使用BluetoothAdapter.getDefaultAdapter()更新蓝牙发现.startDiscovery(); 被打破

我有一个使用蓝牙和连接设备的应用程序,无法使用BluetoothAdapter.getDefaultAdapter()找到任何设备.startDiscovery(); 它在发现之前工作得很好.尝试过其他应用程序,它也不适用于其他应用程序.但我尝试配对的设备(Arduino bt-module)可以在Android设置中找到.知道我能尝试什么吗?我实现了http://developer.android.com/guide/topics/connectivity/bluetooth.html上描述的所有内容,它在更新之前有效.

android bluetooth android-6.0-marshmallow

13
推荐指数
2
解决办法
2万
查看次数