Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7020717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:21:17+00:00 2026-05-27T23:21:17+00:00

So far I have my app taking a picture creating a new folder on

  • 0

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.

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.

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.

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.

UPDATE Thanks to Lumis (code below has been updated)

Changed

intent.putExtra("filepath",uriSavedImage);

to

intent.putExtra("filepath",uriSavedImage.toString());

Which now opens the new Activity but still cannot see the image.

UPDATE 2 Punch.java

I have updated my Punch.java as with the new code if i change (myRef) to "/sdcard/Punch/image_0.jpg" 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 intent.putExtra("filepath",uriSavedImage.toString());

Update 3

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

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

In my Camera Activity I have

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(); // <----
        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); 
    }};

And my Punch.java which is the next Activity is:

    @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);

    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:21:18+00:00Added an answer on May 27, 2026 at 11:21 pm

    I think it is the file path issue. You submitted your file path as URI but you are reading it in the viewer activity as a string.

    Perhaps you neet to change this line into:

    intent.putExtra("filepath",uriSavedImage.toString());
    

    Or

    intent.putExtra("filepath",Uri.parse(output.getAbsolutePath()).toString()); 
    

    Different version of android may not work the same when it comes to file path, so you need to experiment using Uri.parse(fileStr) or String…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I have my app taking a picture AndroidCamera.java using the camera and
I have a great app for capturing shoutcast streams :-) . So far, it
So far i have got the code below which works lovely when trying an
So far I have been creating Web Portal but recently I had a request
I am pretty new to this iPhone dev thing but so far I have
I am very new to Android development, and I am trying to get a
I'm in charge of taking an Excel VBA app and turning it into a
So far I have encountered adjacency list, nested sets and nested intervals as models
So far I have managed to write some code that should print the source
So far I have learned about generating thread dump and heap dump using jstack

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.