title: BLE Scan not working
body: <p>I am a beginner working on a BLE scanner using Google's sample code: <a href="https://github.com/googlesamples/android-BluetoothLeGatt" rel="nofollow noreferrer">https://github.com/googlesamples/android-BluetoothLeGatt</a></p>
  
  <p>Currently, the code is not able to detect any devices. <a href="https://stackoverflow.com/questions/33043582/bluetooth-low-energy-startscan-on-android-6-0-does-not-find-devices">This post</a> says that this is because of location services being disabled or not being explicitly asked for on runtime. I have already included the required permissions in my Manifest.</p>
  
  <p>I have added a few lines of code, which I think should work. </p>
  
  <pre><code>@Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          getActionBar().setTitle(R.string.title_devices);
          mHandler = new Handler();
  
  
          if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
              Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_SHORT).show();
              finish();
          }
  
          // 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);
          mBluetoothAdapter = bluetoothManager.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();
              finish();
              return;
          }
  
  
  
      // Quick permission check
          int permissionCheck = this.checkSelfPermission("Manifest.permission.ACCESS_FINE_LOCATION");
          permissionCheck += this.checkSelfPermission("Manifest.permission.ACCESS_COARSE_LOCATION");
          if (permissionCheck != 0) {
  
              this.requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, 1001); //Any number
          }
  
      }
  </code></pre>
  
  <p>I think the quick permission check I have added should work, but the app still doesn't seem to be detecting any devices.</p>