public class SimpleBluetooth
extends java.lang.Object
| Constructor and Description |
|---|
SimpleBluetooth(android.content.Context context,
android.app.Activity refActivity)
Constructor for
SimpleBluetooth
Allows for easy handling for setting up connections and bluetooth servers to connect to. |
SimpleBluetooth(android.content.Context context,
android.app.Activity refActivity,
BluetoothHandler handler)
Constructor for
SimpleBluetooth Use this constructor to provide your own custom bluetooth
handler. |
| Modifier and Type | Method and Description |
|---|---|
void |
cancelScan()
Cancels the ongoing scan started by
scan() |
void |
connectToA2DPDevice(java.lang.String deviceName)
Connects to an A2DP device.
|
void |
connectToBluetoothDevice(android.bluetooth.BluetoothDevice device)
Connect to a generic bluetooth device.
|
void |
connectToBluetoothDevice(java.lang.String macAddress)
Connect to the bluetooth device knowing only the macAddress.
|
void |
connectToBluetoothServer(java.lang.String macAddress)
Connects to a bluetooth server set up on another device.
|
void |
createBluetoothServerConnection()
Creates a bluetooth server on this device that awaits for a client to connect.
|
void |
endSimpleBluetooth()
Ends all connections and unregister the receiver.
|
BluetoothUtility |
getBluetoothUtility()
Gets the used bluetooth utility.
|
boolean |
initializeSimpleBluetooth()
Method that must be called to set everything up for this service.
|
void |
makeDiscoverable(int duration)
Makes the device discoverable to other devices for a certain amount of time.
|
void |
scan()
Performs a scan of devices directly and does not launch the device dialog.
|
void |
scan(int requestCode)
Starts the device dialog to get a device to connect to.
|
void |
sendData(int data)
Sends data to the connected device.
|
void |
sendData(java.lang.String data)
Sends data to the connected device.
|
void |
setInputStreamType(BluetoothUtility.InputStreamType type)
Sets the input stream type for reading data from the bluetooth device.
|
void |
setSimpleBluetoothListener(SimpleBluetoothListener simpleBluetoothListener)
Sets a simple bluetooth listener for this service.
|
public SimpleBluetooth(android.content.Context context,
android.app.Activity refActivity)
SimpleBluetooth
Allows for easy handling for setting up connections and bluetooth servers to connect to.context - context from the calling activityrefActivity - reference to the calling activity. Context and activity should match.public SimpleBluetooth(android.content.Context context,
android.app.Activity refActivity,
BluetoothHandler handler)
SimpleBluetooth Use this constructor to provide your own custom bluetooth
handler.context - the context of the calling activity.refActivity - reference to the calling activity. Context and activity should match.handler - custom BluetoothHandler for bluetooth event call backs.public void setSimpleBluetoothListener(SimpleBluetoothListener simpleBluetoothListener)
simpleBluetoothListener - the new simple bluetooth listenerpublic void setInputStreamType(BluetoothUtility.InputStreamType type)
type - the InputStreamType, can either be Normal or Buffered.public boolean initializeSimpleBluetooth()
public void sendData(java.lang.String data)
data - The string of data to send.public void sendData(int data)
data - the int to send.public void scan(int requestCode)
requestCode - the request code for the intent. Use this to check against in
OnActivityResult.public void scan()
FoundDeviceReceiver in the activity and you also
need the FoundDeviceReceiver.FoundDeviceReceiverCallBack.public void cancelScan()
scan()public void connectToBluetoothDevice(java.lang.String macAddress)
macAddress - the mac address of the device. If this isn't valid, it won't connect.public void connectToBluetoothDevice(android.bluetooth.BluetoothDevice device)
device - Bluetooth device representing the device.public void createBluetoothServerConnection()
public void connectToBluetoothServer(java.lang.String macAddress)
macAddress - the mac address of the server device. If this isn't valid, it won't connect.public void connectToA2DPDevice(java.lang.String deviceName)
deviceName - the name of the device to connect to.public void makeDiscoverable(int duration)
duration - the duration length in seconds.public void endSimpleBluetooth()
public BluetoothUtility getBluetoothUtility()
BluetoothUtility