studio programacion móviles desarrollo curso aplicaciones java android bluetooth

java - programacion - curso android desarrollo de aplicaciones móviles pdf



¿Problemas con la conexión de Bluetooth SPP en Android? (1)

Me di cuenta de que la razón por la que esto estaba fallando se debía a que ahora tenía el permiso correcto en el archivo de manifiesto.

public class TestConnection extends Activity { /** Called when the activity is first created. */ public static final UUID BluetoothSerialUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); private BluetoothAdapter _adapter; BluetoothSocket socket=null; @Override protected void onPause() { try { socket.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); TextView text = (TextView) findViewById(R.id.mainText); text.setText("This is a test"); String deviceAddress = "05:03:e8:c0:bf:c0"; _adapter = BluetoothAdapter.getDefaultAdapter(); BluetoothDevice device = _adapter.getRemoteDevice(deviceAddress); try { socket = device.createRfcommSocketToServiceRecord(BluetoothSerialUuid); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { socket.connect(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }

}

Estoy tratando de usar algún código de este sitio:

http://zornsoftware.talsit.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

para superar el hecho, android se salta los dispositivos Bluetooth clase 0x00. Sin embargo, cuando hago esto: _adapter.getRemoteDevice (deviceAddress);

Nunca recibo una respuesta