Android examples for android.bluetooth:BluetoothAdapter
check Adapter State On
import android.bluetooth.BluetoothAdapter; import android.util.SparseArray; import java.util.Arrays; import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; public class Main{ /**//from w w w .j a v a2 s. co m * Ensure Bluetooth is turned on. * * @throws IllegalStateException If {@code adapter} is null or Bluetooth state is not * {@link android.bluetooth.BluetoothAdapter#STATE_ON}. */ public static void checkAdapterStateOn(BluetoothAdapter adapter) { if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON) { throw new IllegalStateException("BT Adapter is not turned ON"); } } }