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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:30:58+00:00 2026-06-15T04:30:58+00:00

I have a main Activity A, in which I create a background thread to

  • 0

I have a main Activity A, in which I create a background thread to load data from db. After the loading is done, I want to update the list which might have been already shown in a child activity B (If user has navigated to B in the meanwhile). If user hasnt yet navigated to B, its not an issue.

But how to update B’s list once thread in A has finished?

B is a child of A.

Thanks,

  • 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-15T04:31:00+00:00Added an answer on June 15, 2026 at 4:31 am

    Thanks Imran,

    I handled it by creating an IntentService in a separate class (inner class was not working), and start it from A. After work is done I fire a BroadCast from the IntentService which B’s broadcastreceiver is listening. It updates the list eventually.

    Here is the code:

    In class A, just start the IntentService in for ex OnCreate():

    Intent contactIntent = new Intent(this, ContactLoaderService.class);
            startService(contactIntent);    
    

    Create IntentService like (in a separate class):

    public class ContactLoaderService extends IntentService {
        public ContactLoaderService() {
            super("ContactLoaderService");
        }
    
        @Override
        protected void onHandleIntent(Intent arg0)
        {
            populateContacts();
    
            Intent broadcastIntent = new Intent();
            broadcastIntent.setAction(ContactsResponseReceiver.ACTION_RESP);
            broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT);
            sendBroadcast(broadcastIntent);
        }
    }
    

    In class B I create an inner class which just updates the list like:

    public class ContactsResponseReceiver extends BroadcastReceiver {
        public static final String ACTION_RESP = "com.a.b.c.ContactsLoaded";
    
        @Override
        public void onReceive(Context context, Intent intent) {
            mCurrentAdapter.notifyDataSetChanged();
        }
    }
    

    In B, dont forget to register the receiver. In B’s onCreate() method:

    IntentFilter filter = new IntentFilter(ContactsResponseReceiver.ACTION_RESP);
    filter.addCategory(Intent.CATEGORY_DEFAULT);
    receiver = new ContactsResponseReceiver();
    registerReceiver(receiver, filter);
    

    And the usual service tag in AndroidManifest.xml

    <service android:name="com.a.b.c.ContactLoaderService"> </service>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have main activity in which i have Four menus. and i have one
I am making an app in which i have a main activity that the
I have a Tabhost which is my main activity. When a tab is clicked
If I have a login screen and then the activity which displays the main
Say if I have a locationManager(LM) object in activity A, which is my main
I am making an android app. I have a main activity and i want
I need to have Receive activity which can receive my custom data. I found
I have an app which is basically a launcher with a main activity and
I have a Service class and an main Acitivity class which is supposed to
I have an activity ( MainActivity.java ) in which content view is like this

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.