title: BLUETOOTH_CONNECT permission
body: <p>I have a problem, I try to activate Bluetooth but first I check for BLUETOOTH_CONNECT runtime permission (required by the BluetoothAdapter.enable()).  Every time I request the permission is denied without displaying any dialog box, I tryed to request another permission and it works fine (displays dialog box with options - allow or denie) . I tryed to reinstall the app and clear its cache memory, i also checked for the app permissions allowed but i couldnt find Bluetooth. I also have the permissions in the Manifest.</p>
  <pre><code>public void enableordisableBT() {
  
  
  
     if (MyBluetoothAdapter == null) {
          Log.d(TAG,&quot;Bluetooth not supported&quot;);
      } else if (!MyBluetoothAdapter.isEnabled()) {
          Log.d(TAG,&quot;Bluetooth is currently not enabled&quot;);
  
  
  
  
  
          if (ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.BLUETOOTH_CONNECT) == PackageManager.PERMISSION_GRANTED) {
              Toast.makeText(MainActivity.this, &quot;You have already granted this permission!&quot;, Toast.LENGTH_SHORT).show();
  
              MyBluetoothAdapter.enable();
              IntentFilter BTIntent = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
              registerReceiver(mBroadcastReceiver1, BTIntent);
  
          }
          else
          {
  
              requestConnectPermission();
          }
  
  
  
          } else if (MyBluetoothAdapter.isEnabled()) {
              MyBluetoothAdapter.disable();
  
  
              IntentFilter BTIntent = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED);
              registerReceiver(mBroadcastReceiver1, BTIntent);
  
          }
  
  
      }
  
  
  private void requestConnectPermission() {
      if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.BLUETOOTH_CONNECT)) {
  
          new AlertDialog.Builder(this)
                  .setTitle(&quot;Permission needed&quot;)
                  .setMessage(&quot;This permission is needed because of this and that&quot;)
                  .setPositiveButton(&quot;ok&quot;, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          ActivityCompat.requestPermissions(MainActivity.this,
                                  new String[]{Manifest.permission.BLUETOOTH_CONNECT}, CONNECTION_REQUEST_CODE);
                      }
                  })
                  .setNegativeButton(&quot;cancel&quot;, new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          dialog.dismiss();
                      }
                  })
                  .create().show();
  
      } else {
          ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.BLUETOOTH_CONNECT}, CONNECTION_REQUEST_CODE);
          Log.d(TAG,&quot; permisiune in curs de cerere &quot;);
      }
  
  }
  </code></pre>
  <p>public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {</p>
  <pre><code>    switch (requestCode) {
          case CONNECTION_REQUEST_CODE:
              if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  
                  Toast.makeText(MainActivity.this, &quot;Permission Granted,access to connection available&quot;, Toast.LENGTH_LONG).show();
  
              } else {
                  Toast.makeText(MainActivity.this, &quot;Permission Denied, access to connection unavailable, app requires BLUETOOTH_CONNECT permission in order to operate&quot;, Toast.LENGTH_LONG).show();
  
              }
              break;
          case SCAN_REQUEST_CODE:
              if (grantResults.length &gt; 0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
  
                  Toast.makeText(MainActivity.this, &quot;Permission Granted,access to scan available&quot;, Toast.LENGTH_LONG).show();
  
              } else {
                  Toast.makeText(MainActivity.this, &quot;Permission Denied, access to scan unavailable, app requires BLUETOOTH_SCAN permission in order to operate&quot;, Toast.LENGTH_LONG).show();
  
              }
              break;
      }
  
  }
  </code></pre>