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

Marcel Rob
Marcel Rob
10,282 Points

The Uri memeber variable gets set to null when onActivityResult gets called

so , the mMediaUri gets correctly set to the path in which the picture will be saved after it is taken , but after i take the picture and the device gets back in onActivityResult the mMediaUri variable is null and the app crashes . I think this is because when the camera starts the screen rotates for some reasons . I have read somewhere that on screen roatation the activity recreats . I think that is the point where the mMediaUri loses its value . How can I solve this ??

1 Answer

orbyt
orbyt
10,358 Points

You should really post some code as well as the error. As for the screen orientation, a possible solution is to make the app stay in portrait mode only. Do do this, add the android:screenOrientation:="portrait" property to your manifest.

Marcel Rob
Marcel Rob
10,282 Points

the only way I coul make it work was by using another app to take the photo , I downloaded the camera application from google and it worked fine . There's something with the camera app from the galaxy s4 that makes the app crash , when the camera app ends and the onActivityResult gets called the variables are reset , that doesn't happen with the camera app from google