Back to project page roodroid.
The source code is released under:
Copyright (c) 2011, Jonathan Perichon & Lucas Gerbeaux Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"...
If you think the Android project roodroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package fr.utbm.roodroid; /*w w w . j a v a 2 s. c om*/ import java.io.IOException; import android.bluetooth.BluetoothSocket; import android.os.Handler; import android.util.Log; /** * ConnectionBluetooth * Extends the class Connection. * * It defines the specific connection layer for a bluetooth connection, * which consists in the management of a BluetoothSocket. * * @author Jonathan Perichon <jonathan.perichon@gmail.com> * @author Lucas Gerbeaux <lucas.gerbeaux@gmail.com> * */ public class ConnectionBluetooth extends Connection { private static final long serialVersionUID = -6945126230070252386L; private final BluetoothSocket socket; public ConnectionBluetooth(Handler handler, BluetoothSocket socket) { super(handler); this.socket = socket; try { this.inStream = socket.getInputStream(); this.outStream = socket.getOutputStream(); } catch (IOException e) { ApplicationManager.appendLog(Log.ERROR, "Connection", e.getMessage()); e.printStackTrace(); } } @Override public synchronized void disconnect() { isRunning = false; try { socket.close(); if (ApplicationManager.getInstance().getClient() != null) { ApplicationManager.getInstance().exitClient(); } else { ApplicationManager.getInstance().exitServer(); } } catch (IOException e) { ApplicationManager.appendLog(Log.ERROR, "Connection", e.getMessage()); } catch (Exception e) { e.printStackTrace(); } } @Override public String getAddressSource() { return socket.getRemoteDevice().getAddress(); } }