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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:19:07+00:00 2026-06-17T10:19:07+00:00

I continuously get OutOfMemory exceptions trying to decode an image from camera in my

  • 0

I continuously get OutOfMemory exceptions trying to decode an image from camera in my Android app. There are many questions dealing with the problem, but my case is especially weird because I get the exception even when just trying to get the bounds with options.inJustDecodeBounds=true.

Here’s the code that starts the camera:

protected void takePicture() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File image = new File(IMAGE_PATH, "camera.jpg");
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));
    startActivityForResult(takePictureIntent, 0);
}

Here’s the code that triggers the exception:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK ) { 
        String rawImageName = new String(IMAGE_PATH + "/camera.jpg");

        BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeFile(rawImageName); // The exception is thrown here
            .
            .
            .
    }
}

I tried to decode the image using a very high sampling rate, but still I get the same exception:

options.inSampleSize = 20;
options.inJustDecodeBounds = false;
options.inPreferredConfig = Bitmap.Config.RGB_565;
Bitmap photo = BitmapFactory.decodeFile(rawImageName); // Again the exception

Except for that, the application seems to run correctly and there is enough free memory. I can open correctly the image in the gallery app. Moving the image to a different directory didn’t help. Any ideas what could cause it? What could possibly cause the exception while decoding with inJustDecodeBounds = true?

  • 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-06-17T10:19:08+00:00Added an answer on June 17, 2026 at 10:19 am

    You need to pass the options to the decode call:

    BitmapFactory.decodeFile(rawImageName, options);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get data from a serial port continuously in a very
How can I continuously get data from an NSTextField and do this in the
I am trying to Fetch GPS continuously every minute using Android Code. When it
I'm trying to get Google Maps to continuously pan smoothly over unless the user
Im trying to continuously send small UDP-packets (8 byte) as fast as possible from
I am trying to get a value from my Calculator (which is in its
How can I continuously get the position of the mouse whilst its button is
I have a C# application..I continuously get a null reference exception..I manage to catch
I have created a desktop application which continuously changes the image on a fixed
I want to rotate imageview with continuously looping on android.my code rotate is working

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.