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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:41:22+00:00 2026-05-13T18:41:22+00:00

Here’s scenario: I have 2 activities and one service First activity is a landing

  • 0

Here’s scenario:

  1. I have 2 activities and one service
  2. First activity is a landing view/search page. Second activity displays search results
  3. Search is always executed against internal SQLite db
  4. Periodically (say daily) db needs to be updated from the remote source which is a long process
  5. If user performs the search during the update I want to wait until the update is over while displaying “Please wait” progress alert. I don’t want to query and display search results until refresh is fully done.
  6. The db update is triggered by AlarmManager and executed by service which puts “UPDATING” status into db while update is in progress
  7. I can easily query the status but how do I wait and periodically re-query the database? I’m using AsyncTask to process search results and my knee-jerk reaction was to put a loop with wait() into AsyncTask#doInBackground method but that’s dangerous and simply doesn’t work since I’m not controlling the UI thread so I end up with IllegalMonitorStateException.

What would be a “right” way to properly wait (may be even with status update) in this case?

P.S. I placed the “wait” code into a Runnable and executing it even before I get to my AsyncTask. It works e.g. Thread.sleep(2000) still I’m not sure that’s the way to do it safely. Does anyone have any experience with FutureTask?

  • 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-13T18:41:23+00:00Added an answer on May 13, 2026 at 6:41 pm

    If user performs the search during the
    update I want to wait until the update
    is over while displaying “Please wait”
    progress alert. I don’t want to query
    and display search results until
    refresh is fully done.

    That’s your call, but bear in mind you are creating your own problem. Personally, I’d dump this requirement. The user should not be inconvenienced just because an alarm went off.

    For example, you could disable the alarm and re-enable it when the activity goes away.

    Or, have the update be performed in such a way that it is atomic (e.g., do the update on a copy of the table, then sync the tables in a transaction), so that the activity can still safely access the database while the update is occurring.

    What would be a “right” way to
    properly wait (may be even with status
    update) in this case?

    Have the service tell the activity when the update is done, via some sort of callback, or perhaps a broadcast Intent. Keep the progress indicator alive until this occurs. This still introduces some timing challenges, which is why I’d just dump the requirement.

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

Sidebar

Related Questions

Here the scenario is I have many .aspx pages if any page gives error,
Here is my code (Say we have a single button on the page that
Here's my scenario - I have an SSIS job that depends on another prior
Here is my scenario. I have a website running under AppPool1 and that works
Here's the code I have. It works. The only problem is that the first
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is the scenario. I'm writing my geo-ruby oracle adapter for Ruby On Rails
Here's the basic setup: I have a thin bar at the top of a
Here is my problem : I have a post controller with the action create.

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.