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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:52:48+00:00 2026-05-31T01:52:48+00:00

So, I’ve been debugging an issue in my game, where if I start then

  • 0

So, I’ve been debugging an issue in my game, where if I start then stop it repeatedly, I have noticed that sometimes an Asynctask doesn’t seem to get started, even though I appear to do the right thing to get it started. I’ve removed a lot of unnecessary code to show what happens, but basically I’m seeing that I’m about to start an Asynctask, but the task never gets started.

public void onStart()
{
    super.onStart();
    Log.d(TAG,"About to execute");
    Play_level.execute();
}

AsyncTask<Void,Integer,Integer> Play_level=new AsyncTask<Void, Integer, Integer>(){
     protected void onProgressUpdate(Integer ...time) {
            //Stuff goes in here.
     }
    @Override
    protected Integer doInBackground(Void... params) {
        Log.d(TAG,"In Task");
    }

};

And the logcat shows:

03-10 19:28:16.983: D/Level(1535): About to execute
03-10 19:28:17.503: D/Level(1535): onStop()
03-10 19:28:17.993: D/Level(1535): onPause()
03-10 19:28:19.174: D/AJEG(1535): Starting Tongue
03-10 19:28:19.313: D/Level(1535): ImageList Previously Loaded
03-10 19:28:19.313: D/Level(1535): About to execute
03-10 19:28:19.853: D/Level(1535): onStop()
03-10 19:28:20.283: D/Level(1535): onPause()
03-10 19:28:21.464: D/AJEG(1535): Starting Tongue
03-10 19:28:21.604: D/Level(1535): ImageList Previously Loaded
03-10 19:28:21.604: D/Level(1535): About to execute
03-10 19:28:22.134: D/Level(1535): onStop()
03-10 19:28:22.404: D/Level(1535): onPause()
03-10 19:28:23.504: D/AJEG(1535): Starting Tongue
03-10 19:28:23.644: D/Level(1535): ImageList Previously Loaded
03-10 19:28:23.644: D/Level(1535): About to execute
03-10 19:28:24.184: D/Level(1535): onStop()

Furthermore, no amount of re-entering the task seems to be able to re-start the code, as is shown by the last bit of text.

Just to give a bit more context, Starting Tongue is played in the onStart() of the parent activity (AJEG), Level is the name of the activity I’m starting. The ImageList command can be safely ignored, but I’ve included it for completeness. Part of the doInBackground includes the text “Starting Level _“, where _ is the level that is about to be started. onStop() and onPause() are in the method to show when onStop() and onPause() occur in the Level task.

  • 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-05-31T01:52:49+00:00Added an answer on May 31, 2026 at 1:52 am

    So, the solution to the problem is as stated in this blog article:

    AsyncTask uses a static internal work queue with a hard-coded limit of
    10 elements

    So, essentially I had an AsyncTask that never finished, to the amount of 10, by re-starting my thread so much. To get around this, I did the following:

    1. I converted the AsyncTask to a class, and ensured that only one instance was running, as mah suggested.
    2. I canceled the task in the onStop() command, as Mike D suggested in his comment.
    3. I made sure that I check to see if the ASyncTask is canceled in the doInBackground.

    The result is something like this:

    private LevelPlay Play_level;
    
    public void onStop()
    {
        super.onStop();
        Play_level.cancel(true);
    }
    
    public void onStart()
    {
        super.onStart();
        Play_level=new LevelPlay();
        Play_level.execute();
    }
    
    
    class LevelPlay extends AsyncTask<Void, Integer, Integer>
    {
         protected void onProgressUpdate(Integer ...time) {
         }
        @Override
        protected Integer doInBackground(Void... params) {
            Log.d(TAG,"In Task");
                Boolean keepRunning=true;
            while(keepRunning && !isCancelled ())
            {
                     //DoStuffHere
            }
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.