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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T21:30:23+00:00 2026-05-28T21:30:23+00:00

In my Android application, I have a simple list view with adapter. There’s a

  • 0

In my Android application, I have a simple list view with adapter. There’s a heavy query which is to fill the list view with data. So I put it to an IntentService that runs in another thread.

The IntentService is normally running separately, on its own, just to query some data and insert it into the SQLite database.

But now I would like to have the following possibility:

  1. The activity starts the IntentService with startService().
  2. The IntentService does its heavy work.
  3. When the IntentService is finished, it should inform the activity about the result so that the activity can be refreshed to show the new data.

Is this possible? I read a lot of questions here on Stack Overflow on this topic. But in every question, there was another solution. So I want to ask you all: Which solution is the best for my purpose?

  • Binding the IntentService to the Activity does not seem to be the best solution as there might be conflicts with configuration changes of the activity etc. Correct?
  • This blog post suggests using AIDL with Parcelables – which sounds very complex to me. There is an easier way, isn’t it?
  • One could set up a broadcast receiver in the activity and fire this broadcast in the IntentService when it is finished.
  • Some people say you should use createPendingResult() to pass a PendingIntent to the IntentService. If the IntentService finds that PendingIntent in its extras, it uses this to trigger off onActivityResult() in the Activity. Is this the way to choose?
  • 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-28T21:30:24+00:00Added an answer on May 28, 2026 at 9:30 pm

    As an example, I use a ResultReceiver to call notifyDataSetChanged() on the adapter of my Activity (which extends ListActivity). It can be adapted to do whatever you need.

    ResultReceiver code:

    public class MyResultReceiver extends ResultReceiver {
    
        private Context context = null;
    
        protected void setParentContext (Context context) {
            this.context = context;
        }
    
        public MyResultReceiver(Handler handler) {
            super(handler);
        }
    
        @Override
        protected void onReceiveResult (int resultCode, Bundle resultData) {
    
            // Code to process resultData here
    
            ((BaseAdapter) ((ListActivity)context).getListAdapter()).notifyDataSetChanged();
        }
    }
    

    MyActivity code:

    public class MyActivity extends ListActivity {
    
        private MyResultReceiver theReceiver = null;
    
        ...
    
        private void callService () {
            theReceiver = new MyResultReceiver(new Handler());
            theReceiver.setParentContext(this);
            Intent i = new Intent("com.mycompany.ACTION_DO_SOMETHING");
    
            // Code to define and initialize myData here
    
            i.putExtra("someData", myData);
            i.putExtra("resReceiver", theReceiver);
            startService(i);
    
        }
    }
    

    IntentService code:

    Bundle resultBundle = new Bundle();
    ResultReceiver resRec = intent.getParcelableExtra("resReceiver");
    
    // Do some work then put some stuff in resultBundle here
    
    resRec.send(12345, resultBundle);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple list view with adapter. I create 10+ listviewitems dynamically. Then
In the Android application I have written, there is a portion which allows the
I have two threads in an Android application, one is the view thread, and
i have an android application which has a listview for listing 14 items inside
I am developing simple travel agent android application. When application starts it loads list
I'm trying to create a simple list application for my first app. I have
I have an SQLite database within my Android application, which stores dates as integers.
I have a simple Android application that has a TabBar and one of the
I have a simple string with Chinese characters in my Android application and want
I have an application with tabs. In one tab I need to put data

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.