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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:05:50+00:00 2026-06-07T19:05:50+00:00

I have an activity in my Android app that is trying to use 17

  • 0

I have an activity in my Android app that is trying to use 17 images as bitmap. However when I try to start this activity it returns java.lang.OutOfMemoryError. I really cannot solve this problem. Could anybody who has an exact solution me? My onCreate() is below. Thank you.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.seviyor);

    activityHead=(ImageView) findViewById(R.id.activityhead1);
    shake = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    Options options=new Options();
    options.inSampleSize=1;
    for(int i=0;i<17;i++){  
        bmImages[i]=BitmapFactory.decodeResource(getResources(),drwbles[i] , options);
    }

    initilizeToastBackground();
    initilizeButtonsFor16Leafs();
    initilize16Lisener();

    resultIntent=new Intent(this,ResultFrame.class);
    fortuneCon=16;
    for(int i=0;i<17;i++){
        leafs[i]=(ImageView) findViewById(leafIDs[i]);
    }
    for(int i=0;i<17;i++){
        leafs[i].setImageBitmap(bmImages[i]);
    }


    Bundle frompreviousInent=getIntent().getExtras();
    categoryName=frompreviousInent.getString("category");
    setHeadOfActivity();
}

And this is my LogCat…

    07-12 15:21:11.465: E/AndroidRuntime(23419): FATAL EXCEPTION: main

07-12 15:21:11.465: E/AndroidRuntime(23419): java.lang.OutOfMemoryError

07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.Bitmap.nativeCreate(Native Method)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at com.done.SS.onCreate(SS.java:65)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.Activity.performCreate(Activity.java:4562)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.ActivityThread.access$600(ActivityThread.java:128)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.os.Looper.loop(Looper.java:137)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at android.app.ActivityThread.main(ActivityThread.java:4514)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at java.lang.reflect.Method.invokeNative(Native Method)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at java.lang.reflect.Method.invoke(Method.java:511)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
07-12 15:21:11.465: E/AndroidRuntime(23419):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
07-12 15:21:11.465: E/AndroidRuntime(23419):    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-06-07T19:05:51+00:00Added an answer on June 7, 2026 at 7:05 pm

    Do you need them in full size? Try setting options.inSampleSize = 8. Or at the very least 2 or 4.

    I suspect with 17 images this could be insufficient.

    Another solution would be to query for the images and get them as thumbnails into your Activity:

    Uri tUri = MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI; // Where thumbnails are stored
    String[] columns = { MediaStore.Images.ImageColumns._ID,
                         MediaStore.Images.ImageColumns.DATE_TAKEN,MediaStore.Images.ImageColumns.DISPLAY_NAME};
    
    Cursor thumbCursor = this.managedQuery(tUri, null, null, null, null); // May need to use more paramaters to get
                                                                          // exactly the images you need
    int i = 0;
    if (thumbCursor.moveToFirst() && thumbCursor.getCount() == 17) 
    {
        do
        {
             int columnIndex = thumbCursor.getColumnIndex(MediaStore.Images.Thumbnails.DATA);
             String filePath = thumbCursor.getString(columnIndex);
             Bitmap bitmap = BitmapFactory.decodeFile(filePath);
             leafs[i]=(ImageView) findViewById(leafIDs[i]);
             leafs[i].setImageBitmap(bitmap);
             i++;
         }
         while(thumbCursor.moveToNext());
         thumbCursor.close();
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
I have an Android app which includes an activity called Help This uses a
I have a android webservice client application. I am trying to use the java
I am trying use the onClick() function in an activity for an android app.
I am making an android app. I have a main activity and i want
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;
I have an android app where in my Main activity I can play music
I have an android activity that downloads content from the web. The activity have
I am trying to use a sendOrderedBroadcast in my Android app. I want to
Ok so I have a simple Android app that I want it to go

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.