public class RxBluetooth
extends java.lang.Object
| Constructor and Description |
|---|
RxBluetooth(android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancelDiscovery()
Cancel the current device discovery process.
|
void |
closeProfileProxy(int profile,
android.bluetooth.BluetoothProfile proxy)
Close the connection of the profile proxy to the Service.
|
void |
enableBluetooth(android.app.Activity activity,
int requestCode)
This will issue a request to enable Bluetooth through the system settings (without stopping
your application) via ACTION_REQUEST_ENABLE action Intent.
|
void |
enableDiscoverability(android.app.Activity activity,
int requestCode)
This will issue a request to make the local device discoverable to other devices.
|
void |
enableDiscoverability(android.app.Activity activity,
int requestCode,
int duration)
This will issue a request to make the local device discoverable to other devices.
|
boolean |
isBluetoothAvailable()
Return true if Bluetooth is available.
|
boolean |
isBluetoothEnabled()
Return true if Bluetooth is currently enabled and ready for use.
|
boolean |
isDiscovering()
Return true if the local Bluetooth adapter is currently in the device
discovery process.
|
<any> |
observeBluetoothProfile(int bluetoothProfile)
Observes connection to specified profile.
|
<any> |
observeBluetoothSocket(java.lang.String name,
java.util.UUID uuid)
Opens
BluetoothServerSocket, listens for a single connection request, releases socket
and returns a connected BluetoothSocket on successful connection. |
<any> |
observeBluetoothState()
Observes BluetoothState.
|
<any> |
observeConnectDevice(android.bluetooth.BluetoothDevice bluetoothDevice,
java.util.UUID uuid)
Create connection to
BluetoothDevice and returns a connected BluetoothSocket
on successful connection. |
<any> |
observeDevices()
Observes Bluetooth devices found while discovering.
|
<any> |
observeDiscovery()
Observes DiscoveryState, which can be ACTION_DISCOVERY_STARTED or ACTION_DISCOVERY_FINISHED
from
BluetoothAdapter. |
<any> |
observeScanMode()
Observes scan mode of device.
|
boolean |
startDiscovery()
Start the remote device discovery process.
|
public boolean isBluetoothAvailable()
public boolean isBluetoothEnabled()
Equivalent to:
getBluetoothState() == STATE_ON
Requires Manifest.permission.BLUETOOTH
public void enableBluetooth(android.app.Activity activity,
int requestCode)
activity - ActivityrequestCode - request codepublic boolean startDiscovery()
public boolean isDiscovering()
public boolean cancelDiscovery()
public void enableDiscoverability(android.app.Activity activity,
int requestCode)
activity - ActivityrequestCode - request codepublic void enableDiscoverability(android.app.Activity activity,
int requestCode,
int duration)
activity - ActivityrequestCode - request codeduration - discoverability duration in secondspublic <any> observeDevices()
public <any> observeDiscovery()
BluetoothAdapter.public <any> observeBluetoothState()
BluetoothAdapter.STATE_OFF,
BluetoothAdapter.STATE_TURNING_ON,
BluetoothAdapter.STATE_ON,
BluetoothAdapter.STATE_TURNING_OFF,public <any> observeScanMode()
BluetoothAdapter.SCAN_MODE_NONE,
BluetoothAdapter.SCAN_MODE_CONNECTABLE,
BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLEpublic <any> observeBluetoothProfile(int bluetoothProfile)
BluetoothProfile.ServiceListener.bluetoothProfile - bluetooth profile to connect to. Can be either BluetoothProfile.HEALTH,BluetoothProfile.HEADSET, BluetoothProfile.A2DP,
BluetoothProfile.GATT or BluetoothProfile.GATT_SERVER.ServiceEventpublic void closeProfileProxy(int profile,
android.bluetooth.BluetoothProfile proxy)
Clients should call this when they are no longer using the proxy obtained from observeBluetoothProfile(int).
Profile can be one of BluetoothProfile.HEALTH,BluetoothProfile.HEADSET,
BluetoothProfile.A2DP, BluetoothProfile.GATT or BluetoothProfile.GATT_SERVER.
profile - the Bluetooth profileproxy - profile proxy objectpublic <any> observeBluetoothSocket(java.lang.String name,
java.util.UUID uuid)
BluetoothServerSocket, listens for a single connection request, releases socket
and returns a connected BluetoothSocket on successful connection. Notifies observers
with IOException onError().name - service name for SDP recorduuid - uuid for SDP recordBluetoothSocket on successful connectionpublic <any> observeConnectDevice(android.bluetooth.BluetoothDevice bluetoothDevice,
java.util.UUID uuid)
BluetoothDevice and returns a connected BluetoothSocket
on successful connection. Notifies observers with IOException onError().bluetoothDevice - bluetooth device to connectuuid - uuid for SDP recordBluetoothSocket on successful connection