Android Display Camera Image In New Activity
<p>So far I have my app taking a picture creating a new folder on the SD Card and saving the pictuers into the new folder.</p>

<p>I'm trying to get it so once the picture has been took it will display in a new Activity with two buttons that say "Use" or "Retake". So far the image saving is working perfectly fine but once the image has been took and it tries to open the new Activity it just stays on the camera Activity and shows the image which I cant use as it has a surfaceView onit.</p>

<p>In my LogCat I get the error "Oh, no reference" which is set to show if it can't find the picture, which is why im thinking it may be because I am not calling the picture from the correct place in my Punch.java.</p>

<p>So basiclly I am trying to once an image has been took the app to open a New Activity "Punch.java" and display the image that has just been took.</p>

<p><strong>UPDATE Thanks to Lumis (code below has been updated)</strong></p>

<p>Changed </p>

<p><code>intent.putExtra("filepath",uriSavedImage);</code></p>

<p>to </p>

<p><code>intent.putExtra("filepath",uriSavedImage.toString());</code></p>

<p>Which now opens the new Activity but still cannot see the image.</p>

<p><strong>UPDATE 2 Punch.java</strong></p>

<p>I have updated my Punch.java as with the new code if i change <code>(myRef)</code> to <code>"/sdcard/Punch/image_0.jpg"</code> I can see that image but I need it to referance to the image that was just taken with the camera which is something to do with this line I think <code>intent.putExtra("filepath",uriSavedImage.toString());</code></p>

<p><strong>Update 3</strong></p>

<p>Nearly working perfectly now using <code>intent.putExtra("filepath",Uri.parse(output.getAbsolutePath()).toString());</code> but for some reason it is still putting <code>mnt/sdcard</code> at the start it just needs to be <code>sdcard/</code></p>

<p>Ok now working fine /mnt/sdcard is when the sdcard was mounted to the computer while i took the picture.</p>

<p>In my Camera Activity I have </p>

<pre><code>PictureCallback myPictureCallback_JPG = new PictureCallback(){

    public void onPictureTaken(byte[] arg0, Camera arg1) {
        // TODO Auto-generated method stub
        /*Bitmap bitmapPicture 
            = BitmapFactory.decodeByteArray(arg0, 0, arg0.length);  */
        int imageNum = 0;
        Intent imageIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        File imagesFolder = new File(Environment.getExternalStorageDirectory(), "Punch");
        imagesFolder.mkdirs(); // &lt;----
        String fileName = "image_" + String.valueOf(imageNum) + ".jpg";
        File output = new File(imagesFolder, fileName);
        while (output.exists()){
            imageNum++;
            fileName = "image_" + String.valueOf(imageNum) + ".jpg";
            output = new File(imagesFolder, fileName);
        }

        Uri uriSavedImage = Uri.fromFile(output);
        imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);


        OutputStream imageFileOS;
        try {
            imageFileOS = getContentResolver().openOutputStream(uriSavedImage);
            imageFileOS.write(arg0);
            imageFileOS.flush();
            imageFileOS.close();

            Toast.makeText(AndroidCamera.this, 
                    "Image saved", 
                    Toast.LENGTH_LONG).show();

        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        Intent intent = new Intent(getBaseContext(), Punch.class);
        intent.putExtra("filepath",uriSavedImage.toString());
        //just using a request code of zero
        int request=0;
        startActivityForResult(intent,request); 
    }};
</code></pre>

<p>And my Punch.java which is the next Activity is:</p>

<pre><code>    @Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.punch);

    String myRef = this.getIntent().getStringExtra("filepath");

    File imgFile = new  File(myRef);
    if(imgFile.exists()){

        Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());

        ImageView myImage = (ImageView) findViewById(R.id.imagepunch);
        myImage.setImageBitmap(myBitmap);

    }

}
</code></pre>

<p>}</p>
