M0286_Libro Curso

3: Próximas generaciones

public Button b2; public Button b3; public Button b4;

private static final String TAG = “THINBTCLIENT”; private static final boolean D = true; private BluetoothAdapter mBluetoothAdapter = null; private BluetoothSocket btSocket = null; private OutputStream outStream = null; // Serial Port Profile UUID (RFCOMM 1 (por defecto) si no

esta en uso);

private static final UUID MY_UUID = UUID

.fromString(“00001101-0000-1000-8000

00805F9B34FB”);

// ==> escribimos aqui la mac address del servidor, es decir, // del dispositivo bluetooth del PC <== private static String address = “E8:39:DF:37:3C:2F”; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout. main ); if ( D ) Log.e( TAG , “+++ ON CREATE +++”); mBluetoothAdapter = BluetoothAdapter.

getDefaultAdapter();

if (mBluetoothAdapter == null) {

Toast.makeText(this, “Bluetooth no

disponible.”, Toast. LENGTH_LONG ).show(); finish(); return; }

if (!mBluetoothAdapter.isEnabled()) { Toast.makeText(this, “Por favor, conecte el BT del dispositivo y vuelva a ejecutar la aplicación.”, Toast. LENGTH_LONG ).show(); finish(); return; } if ( D ) Log.e( TAG , “+++ DONE IN ON CREATE, GOT LOCAL BT ADAPTER +++”);

193

Made with FlippingBook - Online catalogs