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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:03:00+00:00 2026-05-26T20:03:00+00:00

(Note that I’ve searched online for the warnings I’m describing below, and have come

  • 0

(Note that I’ve searched online for the warnings I’m describing below, and have come up with next to nothing about them.)

I’m working with API level 10. I have a preference screen (XML-based), and one of the options in there creates a custom ListActivity as follows:

  • PreferenceActivity contains an option that creates a…
    • ListActivity which is a dialog that employs…
      • setOnClickListener() which contains an onClick() method that (right before calling finish()) will startActivity() a new Intent…
        • sub-Activity which starts up an…
          • AsyncTask which does variable time work which when done calls…
          • onPostExecute() which calls finish()

The thing is, it works… but I’m getting a raft of warning starting with:

10-16 21:59:25.010: WARN/WindowManager(170): Rebuild removed 4 windows but added 3
10-16 21:59:25.010: WARN/WindowManager(170): This window was lost:.....

Curiously, this raft of warnings ONLY comes up when the task executes quickly! When I added a Thread.sleep() call to my AsyncTask to artificially inflate its runtime it worked and threw no warnings whatsoever. In fact, as long as it takes more than (roughly) 500 ms to run it works fine. (Note that I tried using startActivityForResult() to no greater effect – the same problem occurs.)


The goal is that the user selects a preference item, they change its setting, some processing takes place, and then the user is left back at the preference menu they started on.

I’m betting it’s a race condition… the order in which the windows are destroyed varies depending on that run-time… and I get the impression that when the sub-Activity closes before its parent ListActivity the warnings get thrown. But sprinkling a 1s sleep() in isn’t a reasonable solution unless this is some sort of Android bug (unlikely, but then again I’ve reproduced a couple of those today already).

So, what’s the flaw in this my that leads to this stream of warnings? It’d be nice to say “on preference, do this, then do that, then finish” but I think what I’m doing is the equivalent. Maybe not… thoughts?


Edit: I decided to try doing this ListActivity as a custom Dialog… that was one of the more painful things I’ve tried to do lately (getApplication() doesn’t work and lots of other things seem to go wrong… it may be inexperience to some extent, but dialogs really weren’t meant for this either…

  • 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-26T20:03:01+00:00Added an answer on May 26, 2026 at 8:03 pm

    Try the following two things:

    • Dismiss your dialog before calling finish() on its parent activity (PreferenceActivity).

    • Make sure you are starting your AsyncTask later in the sub-activity’s lifecycle. I’m specifically thinking you should launch it in onResume().

    My best guess is that the AsyncTask is calling finish() on the sub-activity, before the sub-activity has had a chance to fully start up. Why that would matter? I’m not sure. Something to try though. Good luck!

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

Sidebar

Related Questions

(note that this question is not about CAS, it's about the May fail spuriously
(Please note that I have seen a similar question on StackOverflow recently, however I
Note that when I say client, I mean businesses or organizations that have signed
Note that my activity is NOT extending ListActivity; just Activity. I have a list
I have a string s (note that the a and b are not enclosed
I have the following scenario (note that activity A has launchMode=singleTop ): Activity A
Note that I'm asking about something that will call a callback function more often
Note that much of this code as changed as of edit 3 below. So
Please note that this is asking a question about constructors, not about classes which
NOTE: Before reading this question please note that I have read the previous questions

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.