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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:29:39+00:00 2026-06-15T06:29:39+00:00

I have an IntentService that loads up an ArrayList with data from a network

  • 0

I have an IntentService that loads up an ArrayList with data from a network source (AWS SDB tables). The ArrayList is in a global space — accessible to both the calling Activity and the IntentService (like this: appState = ((App)getApplicationContext())). When the IntentService is done, it notifies the Activity through a ResultReceiver, and the Activity calls adapter.notifyDataChanged() to update the ListView.

This solution works most of the time, … but it violates the rule that only the UI thread should make changes to data underlying a ListView. So as it is, I sometimes get an error: “The content of the adapter has changed but ListView did not receive a notification.”

I think this must be a common situation. Please let me know if you have any suggestions or best practices for this problem. Here are three options I’m aware of:

  1. Keep the IntentService, and have it store the results in another “working” ArrayList, also in the global space. When the result is ready, the IntentService calls the ResultReceiver (on the UI thread), which can then: a) copy the result to the ArrayList associated with the ListView, and b) call adapter.notifyDataChanged(). CONS: I don’t like the idea of putting temp/working data in a global space, and copying the result list seems inefficient.

  2. Keep the IntentService, and have it pass the results back through a bundle loaded with a ParcelableArrayList. CONS: I’m not sure if this approach would scale for very large result sets. It also requires copying the result list.

  3. Switch to a Service which builds a local copy of the result list. Have the Activity directly access the address space of the Service in order to read the result list. CON: Still requires copying results to the ArrayList associated with the ListView.

Thank you.

  • 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-15T06:29:40+00:00Added an answer on June 15, 2026 at 6:29 am

    I switched over to using Parcelable (i.e., option 2 above), and it works fine now. I used the code from this accepted answer as a reference.

    Still testing, but I’m pretty sure the change resolved the error I was getting by updating the adapter’s underlying list off the UI thread. I have yet to try it for lists with > 100 elements, but so far so good. Thanks.

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

Sidebar

Related Questions

I have class that extends 'IntentService' - this class occasionally receives data from a
I have an IntentService that is making a network call and receiving back some
Suppose i have two classes that inherit from IntentService. Now quoting from the documentation
I have an IntentService that is parsing some xlm file to create a html
I have an IntentService that is initially started with the click on a button:
I have an IntentService that downloads some files. The problem is that I create
I have an Android IntentService that is behaving strangely. I am sending it an
I have a service that read users data , like contact , musics ,
In my application I have an IntentService that reads rss feeds. I would like
i have alarm that calls my intentService every 15 min, in the intentService how

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.