public class BluetoothPeer
extends java.lang.Object
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Constructor and Description |
---|
BluetoothPeer(android.app.Activity activity,
android.bluetooth.BluetoothDevice partnerDevice,
java.lang.String serviceName,
BluetoothPeerListener listener,
boolean isVerbose)
Creates a BluetoothPeer instance that tries to connect to the given node using
the given service name.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isConnected()
Returns the connection status.
|
boolean |
isServer()
Checks if the current instance acts as server.
|
void |
releaseConnection()
Releases a connection as client or server.
|
void |
sendDataBlock(int[] data)
Send a block of data to the connected node.
|
public BluetoothPeer(android.app.Activity activity, android.bluetooth.BluetoothDevice partnerDevice, java.lang.String serviceName, BluetoothPeerListener listener, boolean isVerbose)
activity
- the Activity from where to get the BluetoothAdapterpartnerDevice
- the BluetoothDevice of the partner node. If null,
starts immediately as Bluetooth serverserviceName
- the Bluetooth service name used for the communication channellistener
- the BluetoothPeerListener that receives notificationsisVerbose
- if true, information of all data exchanged is displayed in debug consolepublic void sendDataBlock(int[] data)
data
- the data block to sendpublic boolean isConnected()
public void releaseConnection()
public boolean isServer()