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

  • Home
  • SEARCH
  • 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 8854465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:53:12+00:00 2026-06-14T13:53:12+00:00

When I exit my app (by pressing back or the home button) the Activity

  • 0

When I exit my app (by pressing back or the home button) the Activitys onDestroy() method is called (where I do lots of clean up with bitmaps).

When I reopen the app, onCreate() does not get called… it goes straight to onStart(), despite the fact that the Activity was finished. This is causing a “trying to use a recycled bitmap” error.

Is there a way to ensure that onCreate() is always called after an Activity is destroyed?

EDIT: I was mistaken. onCreate() IS being called. However, I am still getting the “trying to use a recycled bitmap” error. If onCreate() is going through all of it’s steps, wouldn’t any recycled bitmaps be reloaded?

  • 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-14T13:53:13+00:00Added an answer on June 14, 2026 at 1:53 pm

    The problem was with how I was setting the ImageView image. My original way to load an image from /res was:

        image.setImageDrawable(getResources().getDrawable(R.drawable.myImage)); //WRONG!!!!
    

    apparently if you recycled a bitmap, the above code will not reallocate memory for the bitmap, and your program will crash when it tries to draw that ImageView.

    The correct way to load a bitmap that has been recycled (or at least, the way that solved my problem) is:

        image.setImageDrawable(new BitmapDrawable(BitmapFactory.decodeResource(getResources(), R.drawable.myImage))); //correct!
    

    It still doesn’t answer my question as to why, after exiting the app, and onDestroy is called, that when I re-enter the app, it is looking for a recycled bitmap. In theory the app should be starting up from scratch.

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

Sidebar

Related Questions

Possible Duplicate: android pressing back button should exit the app I'm building a register
I my testing, when I exit (by pressing the home button) my app, it
Possible Duplicate: android pressing back button should exit the app I am trying to
I've heard that pressing the back button will essentially cause the current Activity to
When in a FB app I want to press an html button and exit
My console app traps SIGINT so it can exit gracefully. Pressing CTRL + C
I found here that to restore brightness on app exit you have to use
We do not want to use exit(0) to make the app close, we do
I am writing this app in windows form c#. When user exit from this
Monitor.Enter and Monitor.Exit are designed to be called from the same thread. But, what

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.