title: Surfaceview is not creating immidiately after asking for runtime permission
body: <p>I am stuck with this issue of <strong>Surfaceview</strong> and <strong>runtime perssion</strong>,</p>
  
  <p>I have requirement of showing the camera preview using the <strong>Surfaceview</strong> at a main activity, So i am asking for the runtime permission when i call the code to show the camera preview.</p>
  
  <p>But I am initializing the Surfaceview immediately after the permission is granted for camera, At that time the <strong>surfaceCreated()</strong> callback never calls and permission is also granted(I have checked from the Settings).</p>
  
  <p>Once i kill the app and open again it works perfect after that.</p>
  
  <p>Here is my initalising code,</p>
  
  <p>in <strong>MainActivity,</strong></p>
  
  <pre><code>@Override
  public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
      initCameraPreview();
  }
  </code></pre>
  
  <p>in initCameraPreview() method,</p>
  
  <pre><code>public void initCameraPreview(){
      StartCameraPreview preview = new StartCameraPreview(context, surfaceView);
  
      preview.onCreate();
  }
  </code></pre>
  
  <p>I have created on class for SurfaceView,
  <strong>StartCameraPreview.java</strong></p>
  
  <pre><code>public StartCameraPreview(Context context, SurfaceView surfaceView) {
      this.mContext = context;
      this.surfaceView = surfaceView;
  }
  
  public void onCreate() {
      if (checkCameraHardware()) {
          mCamera = getCameraInstance();
  
         // configure preview
          previewHolder = surfaceView.getHolder();
          previewHolder.addCallback(surfaceCallback);
          previewHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      }
  }
  </code></pre>
  
  <p>I cannot share much of the code, Sorry.
  So i have just added the initalization code.
  Did anyone face that issue or any one knows any solution for this?</p>
  
  <p>Please help
  Thanks in adv.</p>