From 174928c0aaf020de4514a5c02799299c6e56e4c0 Mon Sep 17 00:00:00 2001 From: Jay Civelli Date: Thu, 8 May 2014 09:24:08 -0700 Subject: Adding a method to know if there is a connection to a BluetoothDevice. Adding a new method to BluetoothDevice that lets callers know whether a remote device is connected. Change-Id: I6f7cb99147f3cdad1d676a93183856dbb4083a06 --- core/java/android/bluetooth/BluetoothDevice.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'core/java/android/bluetooth/BluetoothDevice.java') diff --git a/core/java/android/bluetooth/BluetoothDevice.java b/core/java/android/bluetooth/BluetoothDevice.java index 7f8d0ab..64d80a0 100644 --- a/core/java/android/bluetooth/BluetoothDevice.java +++ b/core/java/android/bluetooth/BluetoothDevice.java @@ -874,6 +874,26 @@ public final class BluetoothDevice implements Parcelable { } /** + * Returns whether there is an open connection to this device. + *

Requires {@link android.Manifest.permission#BLUETOOTH}. + * + * @return True if there is at least one open connection to this device. + * @hide + */ + public boolean isConnected() { + if (sService == null) { + // BT is not enabled, we cannot be connected. + return false; + } + try { + return sService.isConnected(this); + } catch (RemoteException e) { + Log.e(TAG, "", e); + return false; + } + } + + /** * Get the Bluetooth class of the remote device. *

Requires {@link android.Manifest.permission#BLUETOOTH}. * -- cgit v1.1