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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:32:09+00:00 2026-05-17T15:32:09+00:00

I’ve built an application which uses an IntentService for manipulating the application’s database and

  • 0

I’ve built an application which uses an IntentService for manipulating the application’s database and calling web services.

Example:

I have an Activity which is a list of items. This list is populated by a CursorAdapter. Each item has a checkbox and the list is ordered by checked (unchecked items on top and checked items on bottom). When an item’s checkbox is checked, I send an Intent to my IntentService telling it to flag the checked column in the database table for that item, then a message is Broadcasted, the Activity sees it and re-queries the Cursor.

When I’m using a mobile device and start rapidly checking checkboxes, the app essentially hangs. The UI doesn’t hang, but the IntentService in the background does. I can tell because the Cursor on screen isn’t getting refreshed.

It is my understanding that Intents passed to IntentServices are not processed asynchronously. Is that correct? It’s behaving almost like I need to be using semaphores, but I can’t understand why if Intents are queued and processed individually.

Suppose I check 3 checkboxes; so there are 3 Intents queued. After the first one I broadcast a message, which the Activity receives, telling it to requery it’s cursor. Could a potential problem be because I’m requerying the Cursor at the same time I’m processing the second Intent (updating another row in the table)? Querying the Cursor happens on the UI thread.

^ I think this is my problem. What should I use to synchronize this? Semaphores? Can someone point me to some documentation/examples?

Another potential issue is what if my Activity manages a Cursor on a table; also my IntentService queries a Cursor from the same table. I have instances where this happens as my IntentService is going through each row in the Cursor to find items to send to the web service. Though I wouldn’t think this would be a problem so long as the Cursors don’t query at the same time?

Does anyone have any other ideas?

  • 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-17T15:32:09+00:00Added an answer on May 17, 2026 at 3:32 pm

    When an item’s checkbox is checked, I send an Intent to my IntentService telling it to flag the checked column in the database table for that item, then a message is Broadcasted, the Activity sees it and re-queries the Cursor.

    This has a “using a Buick to swat a fly” feel to it.

    It is my understanding that Intents passed to IntentServices are not processed asynchronously. Is that correct?

    onHandleIntent() in your IntentService is called on a background thread, and startService() is always asynchronous.

    It’s behaving almost like I need to be using semaphores, but I can’t understand why if Intents are queued and processed individually.

    Individual Intents are queued and processed serially by the IntentService.

    Could a potential problem be because I’m requerying the Cursor at the same time I’m processing the second Intent (updating another row in the table)?

    This certainly does not help.

    What should I use to synchronize this? Semaphores?

    I’d just use synchronized(someStaticDataMember), but semaphores should work.

    Though I wouldn’t think this would be a problem so long as the Cursors don’t query at the same time?

    The actual query is not executed until the Cursor is touched (e.g., moveToFirst(), getCount()). After that, so long as the query result set is under 1MB, the results are entirely in the Cursor.

    I agree in part with Christopher: use some logging to figure out exactly what is going on, and consider making this a bit more lightweight (e.g., AsyncTask for the database write rather than an IntentService).

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

Sidebar

Related Questions

No related questions found

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.