Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Capturing Photos and Videos Saving a Photo to the Gallery

Slava Fleer
Slava Fleer
6,086 Points

Photos did not save on Ribbit directory

The photos does saves on general camera folder of gellery. The Ribbit folder did created. but photos not appears in Ribbit folder.

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if(resultCode == RESULT_OK) {
            // Add it to gallery
            Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
            mediaScanIntent.setData(mMediaUri);
            sendBroadcast(mediaScanIntent);
        } else if(resultCode == RESULT_CANCELED) {
            Toast.makeText(this, getString(R.string.general_error), Toast.LENGTH_LONG).show();
        }
    }

2 Answers

Slava Fleer
Slava Fleer
6,086 Points

found my mistake. Don't know why, but in

takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, mMediaUri);

instead mMediaUri i put TAKE_PHOTO_REQUEST =(

it was not marked as mistake, and probably put default library of gallery.

Hello,

It won't fix the problem, but it might show if there's an error occurring if you change

} else if(resultCode == RESULT_CANCELED) {

to

} else if(resultCode != RESULT_CANCELED) {

if you keep the ==, it will only show that toast if you hit the back button or cancel the previous activity with any other method. You want the code in that code block to execute when the result isn't ok, but also not cancelled.

Slava Fleer
Slava Fleer
6,086 Points

thanks. i found it already. still waiting for problem solution =)