List of usage examples for android.content.pm PackageManager FEATURE_BLUETOOTH_LE
String FEATURE_BLUETOOTH_LE
To view the source code for android.content.pm PackageManager FEATURE_BLUETOOTH_LE.
Click Source Link
From source file:com.coinblesk.client.utils.UIUtils.java
private static boolean hasBluetoothLE(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); }
From source file:org.bcsphere.bluetooth.tools.Tools.java
static public boolean isBLE(Context context) { if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { return false; } else {//from www . jav a 2s .co m return true; } }
From source file:com.rosterloh.moodring.profile.BleProfileServiceReadyActivity.java
private void ensureBLESupported() { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.no_ble, Toast.LENGTH_LONG).show(); finish();/*from www .j av a 2 s.co m*/ } }
From source file:com.example.RITW.Ble.BleProfileServiceReadyActivity.java
/** * Returns the log session. Log session is created when the device was selected using the {@link ScannerFragment} and released when user press DISCONNECT. * /*from ww w . j a va2s . c o m*/ * @return the logger session or <code>null</code> */ // public ILogSession getLogSession() { // return mLogSession; // } private void ensureBLESupported() { if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.no_ble, Toast.LENGTH_LONG).show(); finish(); } }
From source file:com.nbplus.iotapp.bluetooth.BluetoothLeService.java
/** * Initializes a reference to the local Bluetooth adapter. * * @return Return true if the initialization is successful. */// w ww . j a v a2 s .com @SuppressLint("NewApi") public IoTResultCodes initialize() { // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show(); //finish(); return IoTResultCodes.BLE_NOT_SUPPORTED; } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. if (mBluetoothManager == null) { mBluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); if (mBluetoothManager == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Unable to initialize BluetoothManager."); return IoTResultCodes.BLUETOOTH_NOT_SUPPORTED; } } mBluetoothAdapter = mBluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (mBluetoothAdapter == null) { Toast.makeText(this, R.string.error_bluetooth_not_supported, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Unable to obtain a BluetoothAdapter."); //finish(); return IoTResultCodes.BLUETOOTH_NOT_SUPPORTED; } // Ensures Bluetooth is enabled on the device. If Bluetooth is not currently enabled, // fire an intent to display a dialog asking the user to grant permission to enable it. if (!mBluetoothAdapter.isEnabled()) { return IoTResultCodes.BLUETOOTH_NOT_ENABLED; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mLeScanLollipopCallback = new ScanCallback() { @Override public void onScanResult(int callbackType, ScanResult result) { //super.onScanResult(callbackType, result); try { BluetoothDevice device = result.getDevice(); byte[] scanRecord = result.getScanRecord().getBytes(); final HashMap<Integer, AdRecord> adRecords = AdRecord.parseScanRecord(scanRecord); /** * UUID ? . */ ArrayList<String> scannedUuids = DataParser.getUuids(adRecords); if (scannedUuids == null || scannedUuids.size() == 0) { Log.e(TAG, ">>> xx device name " + device.getAddress() + " has no uuid advertisement"); return; } IoTDevice iotDevice = new IoTDevice(); iotDevice.setDeviceId(device.getAddress()); iotDevice.setDeviceName(device.getName()); iotDevice.setDeviceType(IoTDevice.DEVICE_TYPE_STRING_BT); iotDevice.setUuids(scannedUuids); iotDevice.setUuidLen(DataParser.getUuidLength(adRecords)); iotDevice.setAdRecordHashMap(adRecords); mTempScanedList.put(iotDevice.getDeviceId(), iotDevice); } catch (Exception e) { e.printStackTrace(); } } @Override public void onBatchScanResults(List<ScanResult> results) { //super.onBatchScanResults(results); Log.d(TAG, "mScanCallback.. onBatchScanResults"); } @Override public void onScanFailed(int errorCode) { //super.onScanFailed(errorCode); Log.d(TAG, "mScanCallback.. onScanFailed"); } }; } else { mLeScanKitkatCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord) { Log.d(TAG, ">> mLeScanKitkatCallback.."); try { final HashMap<Integer, AdRecord> adRecords = AdRecord.parseScanRecord(scanRecord); /** * UUID ? . */ ArrayList<String> scannedUuids = DataParser.getUuids(adRecords); if (scannedUuids == null || scannedUuids.size() == 0) { Log.e(TAG, ">>> xx device name " + device.getAddress() + " has no uuid advertisement"); return; } IoTDevice iotDevice = new IoTDevice(); iotDevice.setDeviceId(device.getAddress()); iotDevice.setDeviceName(device.getName()); iotDevice.setDeviceType(IoTDevice.DEVICE_TYPE_STRING_BT); iotDevice.setUuids(scannedUuids); iotDevice.setUuidLen(DataParser.getUuidLength(adRecords)); iotDevice.setAdRecordHashMap(adRecords); mTempScanedList.put(iotDevice.getDeviceId(), iotDevice); } catch (Exception e) { e.printStackTrace(); } } }; } return IoTResultCodes.SUCCESS; }
From source file:com.nbplus.iotapp.service.IoTService.java
/** * ?? ? , enable ? ? ?? .//from ww w.j a v a2s . c o m */ public IoTResultCodes checkBluetoothEnabled() { // Use this check to determine whether BLE is supported on the device. Then you can // selectively disable BLE-related features. if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { return IoTResultCodes.BLE_NOT_SUPPORTED; } // Initializes a Bluetooth adapter. For API level 18 and above, get a reference to // BluetoothAdapter through BluetoothManager. final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE); final BluetoothAdapter bluetoothAdapter = bluetoothManager.getAdapter(); // Checks if Bluetooth is supported on the device. if (bluetoothAdapter == null) { return IoTResultCodes.BLUETOOTH_NOT_SUPPORTED; } // Ensures Bluetooth is enabled on the device. If Bluetooth is not currently enabled, // fire an intent to display a dialog asking the user to grant permission to enable it. if (!bluetoothAdapter.isEnabled()) { return IoTResultCodes.BLUETOOTH_NOT_ENABLED; } mLastConnectionStatus = true; return IoTResultCodes.SUCCESS; }