title: Custom Camera Preview Android
body: <p>I'm trying to create a custom camera preview like the one used by WhatsApp. To illustrate the problem, I'm adding an image below:</p>
  
  <p><a href="http://i.stack.imgur.com/t8CPw.png" rel="nofollow">Example of Preview</a> </p>
  
  <p>I'm using the following code to open the camera activity:</p>
  
  <pre><code>imgCamera.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              File file = new File(path);
              Uri outputFileUri = Uri.fromFile(file);
              Intent intent = new Intent(
                      android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
              intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
              startActivityForResult(intent, 2);
          }
  });
  </code></pre>
  
  <p>And trying the below to show up the preview:</p>
  
  <pre><code>public void onActivityResult(int requestCode, int resultCode, Intent data) {
      if (requestCode == 2 &amp;&amp; resultCode == Activity.RESULT_OK) {
  
          Intent startPreview = new Intent(this.getContext(), PreviewActivity.class);
          startPreview.putExtra("path", path);
          startActivity(startPreview);
      }
      super.onActivityResult(requestCode, resultCode, data);
  }
  </code></pre>
  
  <p>However, it is not showing up my preview custom activity. It is showing the common one.</p>
  
  <p>Could someone help me?</p>
  
  <p>Thank you</p>