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 7436161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:11:42+00:00 2026-05-29T10:11:42+00:00

I set a data member, imageUri, and pass that into an intent that launches

  • 0

I set a data member, imageUri, and pass that into an intent that launches the camera activity. In the camera activity I take a picture and the rotate the screen before clicking the check box to return to my activity. When I do this, imageUri is null when onActivityResult is called. If I don’t rotate the screen everything works just fine and imageUri is not null.

onConfigurationChanged is not geting called in my activity so that is not the issue.

public void takePhoto() {
    //define the file-name to save photo taken by Camera activity
    fileName = getFileNameDate();
    //create parameters for Intent with filename
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, fileName);
    values.put(MediaStore.Images.Media.DESCRIPTION,"Image capture by camera");

    imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);

    //create new Intent
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startActivityForResult(intent, picture_result_code);

}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i("Camera_onActivityResult", "Got activity result requestCode = " + requestCode + " resultCode: " + resultCode);
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case picture_result_code:
        if (resultCode == Activity.RESULT_OK) {
            try {
                Log.i("Camera", "Preparing to upload image...");

                picFile = convertImageUriToFile(imageUri);  // Here imageUri is null and causing crash

                uploadFile(picFile.getPath());

            } catch (Exception e) {
                Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT).show();
                Log.e("Camera", e.toString());
                e.printStackTrace();
            }
        }
    }
}

Is there some other way that I should be retrieving the image?

Thanks

  • 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-29T10:11:43+00:00Added an answer on May 29, 2026 at 10:11 am

    I believe imageUri is a field in your activity, right? if you rotate the device the activity is destroyed and restarted, and your field is null. You have to save the URI as part of the state of your activity. There are a few possible methods to achieve that, on is to use onSaveInstanceState(), see here for more details: http://developer.android.com/reference/android/app/Activity.html#onSaveInstanceState%28android.os.Bundle%29

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

Sidebar

Related Questions

I'm trying to set data in long-term storage in a GreaseMonkey script, except that
Let's say I have an object Employee_Storage that contains a database connection data member.
Say I got an Employee class that has a hire date data member. This
I can set data in JTable constructor, and then user can change this data
I always think of xml like a set data structure. Ie: <class> <person>john</person> <person>sarah</person>
I'm using a particular database table like a Set data structure, i.e., you can
I'm looking for a decent implementation of a set data structure in JavaScript. It
Is there any tricky way to implement a set data structure (a collection of
I have a range named STATE. I want to set data validation in range
Given this data set: ID Name City Birthyear 1 Egon Spengler New York 1957

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.