Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 =)