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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:22:49+00:00 2026-06-03T16:22:49+00:00

Hi after everytime something is destroyed in my game i create a new object

  • 0

Hi after everytime something is destroyed in my game i create a new object of an explosion animation done by the use of a thread class inside my surface view thread. After destroying multiple ships in a short period of time the app exits the activity. Why is this?

explosion ex = new explosion(x,y);
ex.start();

and

class explosion extends Thread implements Runnable{

    private long startTime;
    private int num = 0;
    private int x;
    private int y;
    public explosion(int mx, int my){
        x = mx;
        y = my;
        startTime = System.currentTimeMillis();
    }
    public void run(){
        while(num < 3){
            long millis = System.currentTimeMillis();
            canvas.drawBitmap(explosions.get(num),x,y,null);
            if(millis - startTime > 50){
                startTime = System.currentTimeMillis();
                num++;
                Log.d("Explosion","Animate");
            }
        }
        Log.d("Explosion","End Thread");
    }
};
  • 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-03T16:22:50+00:00Added an answer on June 3, 2026 at 4:22 pm

    Copied from developer.android…

    Regardless of whether or not you use AsyncTask, always remember these
    two rules about the single thread model:

    -Do not block the UI thread,

    -and Make sure that you access the AndroidUI toolkit only on the UI
    thread.

    I believe this line is causing you to crash…

    canvas.drawBitmap(explosions.get(num),x,y,null);
    

    This link details the steps to update UI on another thread:

    http://developer.android.com/resources/articles/painless-threading.html

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

Sidebar

Related Questions

After some experience with functional languages, I'm starting to use recursion more in Java
I am attempting to create a wrapper class for Google Android's Text-To-Speech functionality. However,
I've found out that when I use jQuery to add something to a page
I have a UIViewController and I'm noticing that I've done something to where the
I am having a problem with removing linebreaks after the <h1> tag, as everytime
I'm trying to create buttons after i press a button ( this one is
I'm developing a small social networking app that makes use of something like profile
Everytime I write some data class, I usually spend so much time writing the
I am trying to create a trigger wherein it will insert a new row
Currently after successful login I add md5($username) md5($password) in cookies and then every time

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.