/** * Return true if the local Bluetooth adapter is currently in the device discovery process. * * <p>Device discovery is a heavyweight procedure. New connections to remote Bluetooth devices * should not be attempted while discovery is in progress, and existing connections will * experience limited bandwidth and high latency. Use {@link #cancelDiscovery()} to cancel an * ongoing discovery. * * <p>Applications can also register for {@link #ACTION_DISCOVERY_STARTED} or {@link * #ACTION_DISCOVERY_FINISHED} to be notified when discovery starts or completes. * * <p>If Bluetooth state is not {@link #STATE_ON}, this API will return false. After turning on * Bluetooth, wait for {@link #ACTION_STATE_CHANGED} with {@link #STATE_ON} to get the updated * value. * * <p>Requires {@link android.Manifest.permission#BLUETOOTH}. * * @return true if discovering */ public boolean isDiscovering() { if (getState() != STATE_ON) return false; try { return mService.isDiscovering(); } catch (RemoteException e) { Log.e(TAG, "", e); } return false; }