M0286_Libro Curso
Android
try {
outStream = btSocket.getOutputStream(); Log.e( TAG , “ON RESUME: Output stream creation
} catch (IOException e) {
failed.”, e); }
String message = “Hola, mensaje del cliente al servidor.”; byte [] msgBuffer = message.getBytes(); try { outStream .write(msgBuffer); } catch (IOException e) { Log.e( TAG , “ON RESUME: Exception during write.”, e); }
} @Override public void onPause() { super.onPause(); if ( D )
Log.e( TAG , “- ON PAUSE -”);
if (outStream != null) { try {
outStream .flush(); } catch (IOException e) {
Log.e( TAG , “ON PAUSE: Couldn’t flush
output stream.”, e); } } try {
btSocket.close(); } catch (IOException e2) {
Log.e( TAG , “ON PAUSE: Unable to close socket.”, e2);
}
} @Override public void onStop() { super.onStop(); if ( D ) } @Override public void onDestroy() {
Log.e( TAG , “-- ON STOP --”);
198
Made with FlippingBook - Online catalogs