List of usage examples for android.bluetooth BluetoothAdapter STATE_ON
int STATE_ON
To view the source code for android.bluetooth BluetoothAdapter STATE_ON.
Click Source Link
From source file:Main.java
public static boolean isBluetoothOpen() throws Exception { int bluetoothStateCode = getBluetoothState(); return bluetoothStateCode == BluetoothAdapter.STATE_ON || bluetoothStateCode == BluetoothAdapter.STATE_TURNING_ON ? true : false; }
From source file:Main.java
public static boolean isBluetoothTurnedOn() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); return mBluetoothAdapter != null && mBluetoothAdapter.getState() == BluetoothAdapter.STATE_ON; }
From source file:Main.java
public static boolean isBluetoothEnabled(Context mContext) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) return adapter.getState() == BluetoothAdapter.STATE_ON; return false; }
From source file:Main.java
static public String state2String(int state) { final String ON = "STATE_ON"; final String OFF = "STATE_OFF"; final String TURNING_ON = "STATE_TURNING_ON"; final String TURNING_OFF = "STATE_TURNING_OFF"; switch (state) { case BluetoothAdapter.STATE_ON: return ON; case BluetoothAdapter.STATE_OFF: return OFF; case BluetoothAdapter.STATE_TURNING_ON: return TURNING_ON; case BluetoothAdapter.STATE_TURNING_OFF: return TURNING_OFF; default:// w ww . ja v a2 s .c om return UNKNOWN; } }
From source file:Main.java
public static void toggleBlueTooth(Context context) { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (adapter != null) { switch (adapter.getState()) { case BluetoothAdapter.STATE_OFF: adapter.enable();/*from w ww . j a v a 2 s. c om*/ break; case BluetoothAdapter.STATE_ON: adapter.disable(); break; } } }
From source file:Main.java
public static String getStateString(int state) { switch (state) { case BluetoothAdapter.STATE_CONNECTED: return "Connected"; case BluetoothAdapter.STATE_CONNECTING: return "Connecting"; case BluetoothAdapter.STATE_DISCONNECTED: return "Disconnected"; case BluetoothAdapter.STATE_DISCONNECTING: return "Disconnecting"; case BluetoothAdapter.STATE_OFF: return "Off"; case BluetoothAdapter.STATE_ON: return "On"; case BluetoothAdapter.STATE_TURNING_OFF: return "Turning Off"; case BluetoothAdapter.STATE_TURNING_ON: return "Turning On"; default://from www. ja v a 2 s . co m return "Unknown"; } }
From source file:Main.java
public static boolean isBluetoothAvailable() { BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); if (!adapter.isEnabled()) { if (adapter.getState() == BluetoothAdapter.STATE_OFF) { adapter.enable();//w w w .ja v a 2 s . c o m } } return adapter.getState() == BluetoothAdapter.STATE_ON; }
From source file:Main.java
/** * Ensure Bluetooth is turned on.//w w w .j a va2 s . com * * @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"); } }
From source file:Main.java
/** * Ensure Bluetooth is turned on./* w ww. j av a 2s .co m*/ * * @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"); } }
From source file:org.libreoffice.impressremote.communication.BluetoothServersFinder.java
@Override public void onReceive(Context aContext, Intent aIntent) { if (BluetoothAdapter.ACTION_STATE_CHANGED.equals(aIntent.getAction())) { switch (aIntent.getIntExtra(BluetoothAdapter.EXTRA_STATE, 0)) { case BluetoothAdapter.STATE_ON: startSearch();/*from w w w . java2 s .c o m*/ return; default: return; } } if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(aIntent.getAction())) { LocalBroadcastManager.getInstance(mContext) .sendBroadcast(new Intent(Intents.Actions.BT_DISCOVERY_CHANGED)); return; } if (BluetoothDevice.ACTION_FOUND.equals(aIntent.getAction())) { BluetoothDevice aBluetoothDevice = aIntent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); addServer(aBluetoothDevice); } }