Android Carry Camera Image To New Activity
<p>So far I have my app taking a picture <code>AndroidCamera.java</code> using the camera and then saving the image and displaying it in a new Activity <code>Punch.java</code> which works fine. On this screen there are then two options too use the image or retake the image if the button retake is clicked it will go back to the <code>AndroidCamera.java</code> Activity and if use is clicked it will then go to the Activity <code>BeatEmUp.java</code> which is the new Activity I want to show the image on again.</p>

<p>I just cant figure out what to put in the <code>BeatEmUp.java</code> Activity to display the image again in this new Activity you can see on the code below that I am passing the string from <code>AndroidCamera.java</code> to <code>Punch.java</code> but don't think I can do this again from the <code>Punch.java</code> to <code>BeatEmUp.java</code>?</p>

<p><strong>Update Adil Soomro</strong></p>

<p><code>BeatEmUp.java</code> Activity now force closes when <code>Use</code> button is clicked.</p>

<p>Ok code below has been updated I had to change <code>intent.putExtra("filepath",imagePath);
</code> to <code>Use.putExtra("filepath",imagePath);</code> as with intent at the start it was giving me an error I have also added the <code>BeatEmUp.java</code> as I am not sure if this is correct i thought it would just be the same code as I use to show the image on <code>Punch.java</code></p>

<p><strong>AndroidCamera.java</strong></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",Uri.parse(output.getAbsolutePath()).toString());
        //just using a request code of zero
        int request=0;
        startActivityForResult(intent,request); 
    }};
</code></pre>

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

<pre><code>String imagePath;

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

    imagePath = this.getIntent().getStringExtra("filepath");

    Button buse = (Button) findViewById(R.id.buse);
    buse.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Use = new Intent(Punch.this, BeatEmUp.class);
            Use.putExtra("filepath",imagePath);
            startActivity(Use);                 
        }
    });

    Button bretake = (Button) findViewById(R.id.bretake);
    bretake.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            Intent Retake = new Intent(Punch.this, AndroidCamera.class);
            startActivity(Retake);              
        }
    });

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

    Log.e("&gt;&gt;&gt;", myRef);
    if(imgFile.exists()){

        Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
        ImageView myImage = (ImageView) findViewById(R.id.imagepunch);
        myImage.setImageBitmap(myBitmap);

    }
}

}
</code></pre>

<p><strong>BeatEmUp.java</strong></p>

<pre><code>String myRef = this.getIntent().getStringExtra("filepath");
    File imgFile = new  File(myRef);

    Log.e("&gt;&gt;&gt;", myRef);
    if(imgFile.exists()){

        Bitmap myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
        ImageView myImage = (ImageView) findViewById(R.id.imagepunch);
        myImage.setImageBitmap(myBitmap);
</code></pre>
