android设备之间的蓝牙连接存在问题

android设备之间的蓝牙连接存在问题,android,bluetooth,android-bluetooth,Android,Bluetooth,Android Bluetooth,我刚刚开始使用Android,但今年的考试中,我决定创建一个Android应用程序,它使用蓝牙控制机器人机器。我能够激活蓝牙,显示相关设备并发现新设备。但现在我在连接设备方面遇到了困难 这是发现的代码: private final BroadcastReceiver mReceiver = new BroadcastReceiver() { //tramite il BroadcastReceiver mi metto in ascolto @SuppressWarn

我刚刚开始使用Android,但今年的考试中,我决定创建一个Android应用程序,它使用蓝牙控制机器人机器。我能够激活蓝牙,显示相关设备并发现新设备。但现在我在连接设备方面遇到了困难

这是发现的代码:

      private final BroadcastReceiver mReceiver = new BroadcastReceiver() { //tramite il BroadcastReceiver mi metto in ascolto
        @SuppressWarnings({ "unchecked", "rawtypes" })
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            ArrayList lista = new ArrayList();

            // Quando un il bluetooth trova un dispositivo
            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                // Ottengo i dispositivi 
                BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                Devices.add(device);
                // Aggiungo il nome e l'indirizzo ad un arrayAdapter che verrà mostrato nella listview
                lista.add("Discovered: " + device.getName() + "\n" + device.getAddress());
                Toast.makeText(getApplicationContext(),"Showing New Devices",
                Toast.LENGTH_SHORT).show();
                adapt = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, lista);
                lsv.setAdapter(adapt);
                lsv.setOnItemClickListener(new AdapterView.OnItemClickListener() { // registro una sentinella per monitorare il click/tocco sulla lista. Item indica la riga della lista
                    @Override                                                           
                    public void onItemClick(AdapterView<?> adattore,View view, int position, long id) { //qui stabilisco che fare dopo il click sulla riga
                        // TODO Auto-generated method stub
                        final String titoloriga = (String)adattore.getItemAtPosition(position);
                        Toast.makeText(getApplicationContext(),"Hai cliccato su " + titoloriga,
                                  Toast.LENGTH_SHORT).show();
                        BluetoothDevice selectedDevice = Devices.get(position);
                        ConnectThread connect = new ConnectThread(selectedDevice);
                        connect.start();
                        /*try {
                            Class controlD = Class.forName("com.roborcarcontroller.ListDevices");
                            Intent startCommand = new Intent(MainActivity.this , controlD);
                            startActivity(startCommand);
                        } catch (ClassNotFoundException ex) {
                            // TODO Auto-generated catch block
                            ex.printStackTrace();
                        }*/ 
                    }
                }); 
            }
        }
    };
当我按下“发现”按钮时,出现以下错误:

ZygoteInit$MethodandArgsCaller.run() line 1394

如果有人能帮助我找到解决方案或其他方法,将从listview中选择的蓝牙设备传递到线程,我将非常高兴。

您使用的是可扩展设备还是普通蓝牙设备请提供以下答案:
ZygoteInit$MethodandArgsCaller.run() line 1394