fpuntel 0 Denunciar post Postado Março 4, 2012 Bom dia, Estou tentando conectar meu android em arduino, porém o app nem sequer abre no Android dando um erro, já verifiquei várias vezes o código e não consegui encontrar nada. Alguém poderia me ajudar? Desde já agradeço, Segue abaixo meu código public void onStart(){ super.onStart(); mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if(mBluetoothAdapter != null){ textViewLog.setText(""); textViewLog.append("Bluetooth" + mBluetoothAdapter.toString()); if(!mBluetoothAdapter.isEnabled()) { textViewLog.append("O Bluetooth esta Ativo!!!"); Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } if(mBluetoothAdapter.isEnabled()){ mBluetoothAdapter.startDiscovery(); Set<BluetoothDevice> devices = mBluetoothAdapter.getBondedDevices(); for(BluetoothDevice device : devices) textViewLog.append("Dispositivo encontrado:" + device); textViewLog.append("Conectando"); //MAC PARA CONECTAR String address = "XXXXXXXXXX"; mBluetoothDevice = mBluetoothAdapter.getRemoteDevice(address); textViewLog.setText(mBluetoothDevice.toString() + " " + mBluetoothDevice.getName()); BluetoothSocket tmp = null; try{ tmp = mBluetoothDevice.createRfcommSocketToServiceRecord(MY_UUID); }catch (IOException e){ textViewLog.append("CONEXAO NAO FUNCIONA"); } mySocket = tmp; try{ mySocket.connect(); }catch(IOException e){ textViewLog.append("CONEXAO NAO FUNCIONA"); } try{ MyInStream = mySocket.getInputStream(); } catch (IOException e){ e.printStackTrace(); } if(t == null) { flag_t = true; t = new Thread(){ public void run(){ while(true){ try { bytesIn = MyInStream.read(bufferIn); strTempIn = new String (bufferIn, 0, bytesIn); strBufferIn += strTempIn; }catch(IOException e){ e.printStackTrace(); } //messageHandler.sendMessage(Message.obtain(messageHandler, 1)); } } }; } } }else{ textViewLog.setText("Nao e possivel conectar o Bluetooth"); } Compartilhar este post Link para o post Compartilhar em outros sites
Felipe_Volpatto 1 Denunciar post Postado Março 6, 2012 Cara, ele gera algum erro específico? Se sim, qual? Compartilhar este post Link para o post Compartilhar em outros sites
fpuntel 0 Denunciar post Postado Março 6, 2012 Cara, ele gera algum erro específico? Se sim, qual? Não Felipe, não gera nenhum erro. Compartilhar este post Link para o post Compartilhar em outros sites