public class BluetoothDiscovery
extends java.lang.Object
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
Constructor and Description |
---|
BluetoothDiscovery(android.app.Activity activity)
Creates a BluetoothDiscovery instance to perform Bluetooth discovery actions.
|
Modifier and Type | Method and Description |
---|---|
android.bluetooth.BluetoothDevice |
discoverBluetoothDevice(java.lang.String deviceName)
If a Bluetooth device is supported and it is enabled, starts the
discovery of remote Bluetooth device with given Bluetooth friendly name.
|
static android.bluetooth.BluetoothAdapter |
getBluetoothAdapter(android.app.Activity activity)
Returns the default Bluetooth adapter of the given activity.
|
android.bluetooth.BluetoothDevice |
getPairedDevice(java.lang.String deviceName)
Retrieves the Bluetooth device with given friendly Bluetooth name from
the database of paired devices.
|
java.util.ArrayList<android.bluetooth.BluetoothDevice> |
getPairedDevices()
Returns a list of all remote Bluetooth devices that are paired with the
local device.
|
int |
startBluetoothDiscovery(BluetoothDiscoveryListener listener)
If a Bluetooth device is supported and it is enabled, registers the given
BluetoothDiscoveryListener and starts the discovery of remote
Bluetooth devices.
|
void |
unregisterBroadcastReceiver()
Unregisters the broadcast receiver used for device discovery.
|
public BluetoothDiscovery(android.app.Activity activity)
activity
- the Activity from where to get the BluetoothAdapterpublic int startBluetoothDiscovery(BluetoothDiscoveryListener listener)
listener
- the BluetoothDiscoveryListener that will be notified when
Bluetooth devices are detected and when the discovery process is finishedpublic android.bluetooth.BluetoothDevice discoverBluetoothDevice(java.lang.String deviceName)
deviceName
- the friedly Bluetooth device name of the device to search forpublic java.util.ArrayList<android.bluetooth.BluetoothDevice> getPairedDevices()
public android.bluetooth.BluetoothDevice getPairedDevice(java.lang.String deviceName)
public static android.bluetooth.BluetoothAdapter getBluetoothAdapter(android.app.Activity activity)
public void unregisterBroadcastReceiver()