KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to open a socket bluetooth between a milestone and a pc but the device can not connect. I hope I am sending the code help. public class Bluetooth_V2 extends Activity { public TextView tela; public ListView telaDevice; public BluetoothAdapter bluetooth; public String endBluetooth; public String endDevice; public String nomeDevice; public ArrayAdapter<String> nomeBluetooth; private static final String info = "DEBUG"; private static final int DISCOVERABLE_REQUEST = 0; private static final int DISCOVERY_REQUEST = 0; public BroadcastReceiver mReceiver = null; public ArrayList<String> deviceDescoberto; public BluetoothDevice deviceRemoto; public BluetoothServerSocket btserver; public BluetoothSocket serverSocket; public UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); public OutputStream outStream; public InputStream instream; public BluetoothSocket socket; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tela = (TextView) findViewById(R.id.telaMsg); telaDevice = (ListView) findViewById(R.id.telaDevice); bluetooth = BluetoothAdapter.getDefaultAdapter(); nomeBluetooth = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1); telaDevice.setAdapter(nomeBluetooth); Log.d(info, "Recebeu adaptador"); if(bluetooth==null) { Log.d(info,"Bluetooth nao suportado"); tela.append("Bluetooth nao suportado"); } if(!bluetooth.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent,RESULT_OK); } tela.append("\nNome:"+bluetooth.getName()); tela.append("\nEndereço:"+bluetooth.getAddress()); bluetooth.startDiscovery(); Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); startActivity(discoverableIntent); //discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCO
Tags (comma-separated)
Save Edits
Cancel