Android examples for Bluetooth:Turn On bluetooth
Ensure Bluetooth is turned on.
import android.bluetooth.BluetoothAdapter; public class Main { /**/*w ww. j a v a2 s . com*/ * Ensure Bluetooth is turned on. * * @throws IllegalStateException * If {@code adapter} is null or Bluetooth state is not * {@link BluetoothAdapter#STATE_ON}. */ static void checkAdapterStateOn(BluetoothAdapter adapter) { if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON) { throw new IllegalStateException("BT Adapter is not turned ON"); } } }