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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:33:58+00:00 2026-05-19T23:33:58+00:00

i am picking images on my app with android, and i dont know why,

  • 0

i am picking images on my app with android, and i dont know why, sometimes i got an exception, i think it’s allways i select a image with more than 400 or 500 kb’s but i am not sure. Why? because when i select small images of 100 kb i dont get the exception, and when i get images with high KB or MB, it crash WITH java.lang.OutOfMemoryError: bitmap size exceeds VM budget. BUT VERY IMPORTANT: it crashes on the emulator but ALSO CRASH ON MY PHONE, is not a failure of the emulator.

this is my code:

changeImageButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent i = new Intent(Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
                startActivityForResult(i, ACTIVITY_SELECT_IMAGE);
            }
        }); 



protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) { 
        super.onActivityResult(requestCode, resultCode, imageReturnedIntent); 

        switch(requestCode) {
        case 1:
        {
            setResult(1);
            finish();    
        }
        case ACTIVITY_SELECT_IMAGE:
            if(resultCode == RESULT_OK){  
                Uri selectedImage = imageReturnedIntent.getData();
                String[] filePathColumn = {MediaStore.Images.Media.DATA};

                Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
                cursor.moveToFirst();

                int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
                String filePath = cursor.getString(columnIndex);
                cursor.close();

                selectedPhoto = BitmapFactory.decodeFile(filePath);
                //profileImage.setImageBitmap(selectedPhoto);
                profileImage.setImageBitmap(Bitmap.createScaledBitmap(selectedPhoto, 80, 80, false));
            }
        }
    }

profileImage is a ImageView of my layout. and i use scaled butmap to resice the image to 80×80

please give me some help with this exception, i need to solve it

this is the exception:

 01-31 12:38:37.531: ERROR/AndroidRuntime(1025): Uncaught handler: thread main exiting due to uncaught exception
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:375)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:171)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:196)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at com.GPSLoc.Configuration.onActivityResult(Configuration.java:253)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.Activity.dispatchActivityResult(Activity.java:3595)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3001)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3047)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.ActivityThread.access$2300(ActivityThread.java:112)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1721)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.os.Handler.dispatchMessage(Handler.java:99)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.os.Looper.loop(Looper.java:123)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at android.app.ActivityThread.main(ActivityThread.java:3948)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at java.lang.reflect.Method.invokeNative(Native Method)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at java.lang.reflect.Method.invoke(Method.java:521)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
    01-31 12:38:37.552: ERROR/AndroidRuntime(1025):     at dalvik.system.NativeStart.main(Native Method)
  • 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-19T23:33:59+00:00Added an answer on May 19, 2026 at 11:33 pm

    Bitmap.createScaledBitmap method as long as I have researched has a highpoint of memory consumption and produces that error, but, I’m not totally sure about it. Anyway it is JAVA API and you cannot go deeper.

    You can do the next:

    //create a Drawable with your image as parameter
    BitmapDrawable d= new BitmapDrawable(youBitmap);
    //define bounds for your drawable       
    int left =0;
    int top = 0;
    int right=80;
    int bottom=80;
    
    Rect r = new Rect(left,top,right,bottom);
    //set the new bounds to your drawable       
    d.setBounds(r);
    //set the drawable as view of your image view
    profileImage.setImageDrawable(d); 
    

    I have not tested this code, but it should work.

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

Sidebar

Related Questions

WHAT I HAVE DONE NOW: i am picking images on my app with android,
In my iPhone App I am picking image from iPhone Image Library as well
I am now trying to implement a app like picking image and video from
I am using gallery picker for picking an image from gallery. The photos taken
I am trying to save a image by picking it from iphone photo library.
I am new to Android development so have been picking things up over the
I have used og:image tag with my facebook share button. It is not picking
Android - when getting images from Gallery, they are with wrong orientation. For example,
I want to mail a file (image) as an attachment by just picking it
I've just created a custom carousel with images and have got previous/next arrows to

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.