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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:13:21+00:00 2026-06-13T18:13:21+00:00

I develop one android app for book read. The Book pages and audios are

  • 0

I develop one android app for book read. The Book pages and audios are download from Amazon Bucket. After downloading it stores on SD Card.

I place to two button for next and previous pages. When I display pages It gives me Out of Memory Exception.

11-03 10:59:39.199: E/AndroidRuntime(13566): FATAL EXCEPTION: main
11-03 10:59:39.199: E/AndroidRuntime(13566): java.lang.OutOfMemoryError
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at  android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:299)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:324)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.graphics.drawable.Drawable.createFromPath(Drawable.java:880)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at org.Infoware.childrenbible.GeneralHelper.setImgfromSDCard(GeneralHelper.java:608)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at org.Infoware.childrenbible.CoverPageActivity.onCreate(CoverPageActivity.java:205)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.Activity.performCreate(Activity.java:4465)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.ActivityThread.access$600(ActivityThread.java:123)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.os.Looper.loop(Looper.java:137)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at android.app.ActivityThread.main(ActivityThread.java:4424)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at java.lang.reflect.Method.invokeNative(Native Method)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at  java.lang.reflect.Method.invoke(Method.java:511)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11-03 10:59:39.199: E/AndroidRuntime(13566):    at dalvik.system.NativeStart.main(Native Method)

Here It my Java Code:

public class PageReadActivity extends Activity 
{
    Bitmap bitmap;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
        super.onCreate(savedInstanceState);
    try 
    {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.pageread_layout);
     } 
    catch (Exception ex) 
    {
        ex.printStackTrace();
        Log.d(TAG, "Error in onCreate");
    }
}

  @Override
  protected void onStart() {
    // TODO Auto-generated method stub
    super.onStart();
    displayPage(product_code, page_Index);

      btnNext.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
                          page_Index = page_Index + 1;
                 displayPage(product_code, page_Index);

            }
        });

       btnPrevious.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                // TODO Auto-generated method stub
             page_Index = page_Index - 1;
    displayPage(product_code, page_Index);

            }
        });

   }

      private void displayPage(String product_code, int ind) 
{
    try 
    {
        String imageName = product_code + ind + ".jpg";

        String imgFilePath = objHelper.getFullFilePath(imageName);

        File imageFile = new File(imgFilePath);

        imgViewPage = new ImageView(myContext);

        if(imageFile.exists())
        {   

            bitmap = objHelper.decodeSampledBitmapFromResource(imageName,objHelper.screenWidth,objHelper.screenHeight);             

            imgViewPage.setImageBitmap(bitmap);
            bitmap = null;

            String audioName = product_code+"_audio" + ind + ".mp3";
            String audioFilePath = objHelper.getFullFilePath(audioName);

            File audioFile = new File(audioFilePath);

            if(audioFile.exists())
            {   
                progressBarWaiting.setVisibility(View.INVISIBLE);
                stopAudio();
                playAudio(ind);
            }

        }
        else
        {
            System.out.println("Image not exists.....");
        }           
    } 
    catch (Exception ex) 
    {
        ex.printStackTrace();
        Log.e(TAG, "ERROR in displayPage");
    }
}

    @Override
protected void onDestroy() 
{
    super.onDestroy();
    objHelper.unbindDrawables(findViewById(R.id.pageReadLayout));
    System.gc();
}

    public void unbindDrawables(View view) 
{
    if(view.getBackground() != null)
    {
        view.getBackground().setCallback(null);
    }

    if(view instanceof ViewGroup && !(view instanceof AdapterView))
    {
        for (int i = 0; i < ((ViewGroup) view).getChildCount(); i++) 
        {
            unbindDrawables(((ViewGroup) view).getChildAt(i));
        }

        ((ViewGroup) view).removeAllViews();
    }
}

    public Bitmap decodeSampledBitmapFromResource(String fileName,int reqWidth, int reqHeight) 
{

    String imagePath = getFullFilePath(fileName);

    @SuppressWarnings("unused")
    File imgFile = new File(imagePath);

    // First decode with inJustDecodeBounds=true to check dimensions
    final BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(imagePath,options);

    // Calculate inSampleSize
    options.inSampleSize = 1;

    // Decode bitmap with inSampleSize set
    options.inJustDecodeBounds = false;

    return BitmapFactory.decodeFile(imagePath,options);
}
   }
  • 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-13T18:13:22+00:00Added an answer on June 13, 2026 at 6:13 pm

    Bitmap converts the original size of the image x 4. So it occupies more heap which is specified to your app by android.

    Use this when your Bitmap is no longer needed

    bitmap.recycle();
    bitmap = null;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I develop one app for android, on eclipse. It works in the emulator, very
i develop one application in android i want to see my app in app
Hi i have to develop one expandablelistview android app.here i wish to create relativelayout
In Android you can use Fragments to develop only one app targeted to phones
I have to develop one android app. Here I wish to go back means
Trying to develop an android app that integrates social networking, and the first one
I develop one book reader application which play audio according to page, but problem
I wanted to develop a Django app and one of the functionalities I'd like
I am trying to develop an android app, where user should be able to
I planed to develop android app to sync outlook exchange contacts and mail 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.