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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:24:05+00:00 2026-06-17T08:24:05+00:00

So here’s the deal, I’ve searched every single question and link online but none

  • 0

So here’s the deal, I’ve searched every single question and link online but none are helpful.
I have 120 frames of an animation in .jpg format for my splash screen. I understand that jpegs are converted to bitmaps on memory so that’s why I get an OutOfMemoryError. The maximum frames I get to animate are 10. Is there any way to do this frame by frame, or should I try something else. Here’s my code:

    final AnimationDrawable anim = new AnimationDrawable();
    anim.setOneShot(true);

    for (int i = 1; i <= 120; i++) 
    {
        Drawable logo = getResources().getDrawable(getResources()
                  .getIdentifier("l"+i, "drawable", getPackageName()));

        anim.addFrame(logo, 50);
        if (i % 3 == 0)
        {
            System.gc();
        }
    }

    ImageView myImageView = (ImageView) findViewById(R.id.SplashImageView);
    myImageView.setBackgroundDrawable(anim);
    myImageView.post(new Runnable()
    {
       public void run()
       {
          anim.start();
       }
    });

I’ve placed the 120 jpegs under the drawable folder with an “l” prefix (eg l1, l2 etc).
I do garbage collection every 3 jpegs but that won’t do a thing.

  • 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-17T08:24:06+00:00Added an answer on June 17, 2026 at 8:24 am

    You can try to do it without AnimationDrawable using Handler.postDelayed. Something like this:

    final ImageView image = (ImageView) findViewById(R.id.SplashImageView);
    final Handler handler = new Handler();
    
    final Runnable animation = new Runnable() {
        private static final int MAX = 120;
        private static final int DELAY = 50;
    
        private int current = 0;
    
        @Override
        public void run() {
            final Resources resources = getResources();
            final int id = resources.getIdentifier("l" + current, "drawable", getPackageName());
            final Drawable drawable = resources.getDrawable(id);
    
            image.setBackgroundDrawable(drawable);
            handler.postDelayed(this, DELAY);
            current = (current + 1) % MAX;
        }
    };
    
    handler.post(animation);
    

    This solution requires less memory because it keeps only one drawable at the time.

    You can cancel the animation using handler.removeCallbacks(animation);.

    If you want make a one-shot animation you can call handler.postDelayed conditionally:

    if (current != MAX - 1) {
        handler.postDelayed(this, DELAY);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my situation. I have a DotNetNuke application. I want to link to an
Here's a newbie question, but how do I use dates for the x-axis in
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here's my problem I have this javascript if (exchRate != ) { function roundthecon()
here is a link to how my APC is running : [removed] As you
Here is what I want to do. Use this HTML line and have the
Here's the setup - I have a view that lists products. On that same
Here's the link: www.mchenry.edu/maps/google.asp Why won't the location balloon display correctly? Also, the pop-up
Here is the situation. I am making changes to an application but I do

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.