List of usage examples for android.bluetooth BluetoothAdapter isEnabled
@RequiresPermission(Manifest.permission.BLUETOOTH) public boolean isEnabled()
From source file:Main.java
public static void startBluetooth() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter != null) { if (!bluetoothAdapter.isEnabled()) { bluetoothAdapter.enable();/*from www . j av a 2s . co m*/ } } }
From source file:org.chromium.chrome.browser.physicalweb.Utils.java
public static int getBluetoothEnabledStatus() { int statusResult = RESULT_INDETERMINATE; if (isBluetoothPermissionGranted()) { BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter(); statusResult = (bt != null && bt.isEnabled()) ? RESULT_SUCCESS : RESULT_FAILURE; }/*from w ww . j a v a2 s . co m*/ return statusResult; }
From source file:Main.java
public static boolean isDiscoverable() { BluetoothAdapter bluetoothDefaultAdapter = BluetoothAdapter.getDefaultAdapter(); if ((bluetoothDefaultAdapter != null) && (bluetoothDefaultAdapter.isEnabled())) { if (bluetoothDefaultAdapter.getScanMode() == BluetoothAdapter.SCAN_MODE_CONNECTABLE_DISCOVERABLE) return true; }// w w w. ja v a 2 s . co m return false; }
From source file:Main.java
public static boolean isBluetoothEnabled(Context context) { if (checkPermission(context, Manifest.permission.BLUETOOTH)) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter != null) { return mBluetoothAdapter.isEnabled(); }/*from ww w. j a v a 2s. c o m*/ } return false; }
From source file:Main.java
public static boolean isBluetoothEnable() { BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (bluetoothAdapter == null) { return false; } else {/*from w ww . java2 s . c o m*/ return bluetoothAdapter.isEnabled(); } }
From source file:Main.java
static public boolean checkBluetoothAvaliability() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { return false; } else {// w w w. ja v a 2 s .co m if (mBluetoothAdapter.isEnabled()) { return true; } else { return false; } } }
From source file:Main.java
/** * Check Blue tooth status//from w w w . j a v a 2 s .com * @return */ public static boolean isBluetoothOn() { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // Check device supporting blue tooth or not if (mBluetoothAdapter != null) { return mBluetoothAdapter.isEnabled(); } return false; }
From source file:Main.java
public static int getBleStatus(Context context) { // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { return STATUS_BLE_NOT_AVAILABLE; }/*ww w . ja v a 2 s . co m*/ final BluetoothAdapter adapter = getBluetoothAdapter(context); // Checks if Bluetooth is supported on the device. if (adapter == null) { return STATUS_BLUETOOTH_NOT_AVAILABLE; } if (adapter.isEnabled()) { return STATUS_BLUETOOTH_DISABLED; } return STATUS_BLE_ENABLED; }
From source file:Main.java
public static boolean initializeBluetooth(Activity activity) { BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { // Device does not support Bluetooth return false; }/*from w w w.ja va 2s.c o m*/ int REQUEST_ENABLE_BT = 1; if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); activity.startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } return false; }
From source file:Main.java
/** * Check if bluetooth function enabled/*from ww w . j av a 2s . com*/ * * @param context the context * @return true if bluetooth enabled */ public static boolean isBluetoothEnabled(@NonNull Context context) { BluetoothManager bluetoothManager = (BluetoothManager) context.getSystemService(Context.BLUETOOTH_SERVICE); if (bluetoothManager == null) { return false; } final BluetoothAdapter bluetoothAdapter; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { bluetoothAdapter = bluetoothManager.getAdapter(); } else { bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); } if (bluetoothAdapter == null) { return false; } return bluetoothAdapter.isEnabled(); }