title: onRequestPermissionsResult is not called in Activity
body: <p>I searched for similar questions like this and followed the approaches in the answers but none of them worked for me. I know such questions have been asked previously. I am testing my app on Android 6.0 API 23. The permission dialog opens when i click on Allow the permission is granted but <strong>onRequestPermissionsResult</strong> is never called. None of the toasts appears on the screen whether i click on Allow or Deny. I know i am missing something but I can't figure it out.</p>
  
  <pre><code>public class MainActivity extends Activity {
  private static final String TAG = "MainActivity";
  Camera camera;
  Preview preview;
  ImageButton buttonClick;
  ProgressBar progressBar;
  public static Bitmap bitmap;
  @Override
  public void onCreate(Bundle savedInstanceState) {
      Log.e(TAG,"onCreate");
      super.onCreate(savedInstanceState);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
      setContentView(R.layout.activity_main);
      progressBar = (ProgressBar) findViewById(R.id.progressbar);
      buttonClick = (ImageButton) findViewById(R.id.imageButton);
      progressBar.setVisibility(View.GONE);
  
      int currentapiVersion = android.os.Build.VERSION.SDK_INT;
      //// if API &gt;= 23 equest permisions
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M &amp;&amp; (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA)
              != PackageManager.PERMISSION_GRANTED)) {
          ActivityCompat.requestPermissions(MainActivity.this,new String[]{"android.permission.CAMERA" }, 0);
      }else{
          moveOn();
      }
  
      buttonClick.setOnClickListener( new OnClickListener() {
          public void onClick(View v) {
              progressBar.setVisibility(View.VISIBLE);
              AudioManager mgr = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
              mgr.setStreamMute(AudioManager.STREAM_SYSTEM, true);
              preview.camera.takePicture(null, rawCallback, jpegCallback);
          }
      });
  }
  
  private void moveOn() {
      preview = new Preview(this);
      ((FrameLayout) findViewById(R.id.preview)).addView(preview);
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      finish();
  }
  
  
  
  PictureCallback rawCallback = new PictureCallback() {
      public void onPictureTaken(byte[] data, Camera camera) {
          Log.e(TAG,"onPictureTaken in rawCallback ");
      }
  };
  
  PictureCallback jpegCallback = new PictureCallback() {
      public void onPictureTaken(byte[] data, Camera camera) {
          bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
          Log.e(TAG,"onPictureTaken in jpegCallback ");
          camera.stopPreview();
          //finish();
          Intent k = new Intent(MainActivity.this, ImageSet.class);
          startActivity(k);
          progressBar.setVisibility(View.GONE);
      }
  };
  
  //This method will be called when the user will tap on allow or deny
  @Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  super.onRequestPermissionsResult(requestCode, permissions, grantResults);
      //Checking the request code of our request
      if(requestCode == 0){
  
          //If permission is granted
          if(grantResults.length &gt;0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED){
  
              //Displaying a toast
              Toast.makeText(this,"Permission granted to use Camera",Toast.LENGTH_LONG).show();
          }else{
              //Displaying another toast if permission is not granted
              Toast.makeText(this,"Oops you just denied the permission",Toast.LENGTH_LONG).show();
          }
      }
  }
  </code></pre>