title: calling a function from dialogclass
body: <p>This is my <strong>DialogClass</strong></p>
  
  <pre><code>public android.app.Dialog onCreateDialog(Bundle savedInstanceState) {
  
      DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface argo0, int arg1) {
              switch (arg1){
  
                  case 0:
                      selection=(String) items[arg1];
                      break;
                  case 1:
                      selection=(String) items[arg1];
                      break;
                  case 2:
                      selection=(String) items[arg1];
                      break;
                  case 3:
                      selection=(String) items[arg1];
                      break;
                  case 4:
                      selection=(String) items[arg1];
                      break;
                  case 5:
                      selection=(String) items[arg1];
                      break;
              }
          }
      }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
              Camera2BasicFragment q= new Camera2BasicFragment();
              q.c();
  
          }
      });
      return builder.create();
      // return super.onCreateDialog(savedInstanceState);
  }
  }
  </code></pre>
  
  <p>I am calling a function c from parent class Camera2BasicFragment, but its returning an error.</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 
  'android.graphics.SurfaceTexture 
  com.example.android.camera2basic.AutoFitTextureView.getSurfaceTexture()' on 
  a null object reference
  </code></pre>
  
  <p>How do you call a function inside a dialogclass???</p>
  
  <p>Error occurs in the line
      SurfaceTexture texture = mTextureView.getSurfaceTexture();</p>
  
  <p>of the class c</p>
  
  <pre><code>public void c() {
  
      try {
          SurfaceTexture texture = mTextureView.getSurfaceTexture();
          assert texture != null;
  
          // We configure the size of default buffer to be the size of camera preview we want.
          texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight());
  
          // This is the output Surface we need to start preview.
          Surface surface = new Surface(texture);
  </code></pre>