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

  • Home
  • SEARCH
  • 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 6208687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:51:00+00:00 2026-05-24T05:51:00+00:00

I have a fairly complex problem. I have read some similar posts to my

  • 0

I have a fairly complex problem. I have read some similar posts to my problem but in a slightly different situation.

I have an Activity with a List View. The Activity creates a thread with a long running process. After the process ends, it calls the handler to update the listview and play a sound. It works fine if I’m in the same Activity, but when I click on HOME button while the process is running, then press on the shortcut or application icon to launch the Activity, then when the process ends, I hear the sound but the list view is not updated. Any ideas why this is happening? Some people and me as well are getting the same issues with orientation change.

// thread created to send the reply.
   Thread replyThread = new Thread() {
public void run() {
    **Http POST here to upload an image which takes a while.    
//Once done, send a msg to handler to play a sound and update listview  
Message msg = replyHandler.sendEmptyMessage(0);         
}
   }

Handler:

final Handler replyHandler = new Handler() {
    public void handleMessage(Message msg) {
    fillData();
    **Code to play sound.
    }
}

fillData() method

// refresh the listview.
private void fillData() {
    // Get all of the rows from the database and create the item list

            **I actually have an activity before this one but to simplify the problem I said I have 1 Activity. Bundle is from previous Activity.

            String conversationId = "";

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        conversationId = extras
                .getString(TestDbAdapter.KEY_CONVERSATION_ID);          
    }

    if (mDbHelper != null) {        

        Cursor notesCursor = mDbHelper
                .fetchAllMessagesByConversationId(conversationId);
        startManagingCursor(notesCursor);

        String[] from = new String[] { TestDbAdapter.KEY_BODY,
                TestDbAdapter.KEY_TIMESTAMP };

        int[] to = new int[] { R.id.text1, R.id.text2 };

        // Now create a simple cursor adapter and set it to display
        MessagesCursorAdapter notes = new MessagesCursorAdapter(this,
                R.layout.messages_row, notesCursor, from, to, mDbHelper);
        setListAdapter(notes);

    }

}

I know some people are gonna say “Use notifyDataSetChanged instead”, done that. The code above works in the same manner as notifyDataSetChanged but maybe not in a very elegant way but in my case it works, but it doesn’t help with the problem I’m having using notifyDataSetChanged.

  • 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-24T05:51:01+00:00Added an answer on May 24, 2026 at 5:51 am

    When the home button is pressed and activity restarted a “new” activity is created.

    Your callback from the long running process will be sent to the old activity, not the new activity.

    A similar thing happens with orientation changes, each orientation change creates a new activity (that will not receive the callback).

    There are a couple of methods I am aware of to deal with this:

    • Store the state & results of the long running process in local storage (db, xml, contentprovider etc) and query for state & results when the activity starts. The Google IO REST talk talks about the problem and a pattern you can implement to solve it. (Note: fairly large amount of work to implement this pattern fully)
    • Route the callbacks through your Application class and register your activities when they start with the Application so it knows which one to send callbacks to. Droid-fu contains some utilities that can help implement this
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a fairly complex model needing to be validated, the problem is that
I have a fairly complex CLR stored procedure. What is the best way to
Our users have created MS-Excel spreadsheets which over time have evolved into fairly complex
I have a fat GUI that it getting fairly complex, and I would like
I have a fairly simple const struct in some C code that simply holds
I have a fairly complex page which contains an absolutely positioned table (as the
In my MVC application I have a problem with passing data from view to
I have a fairly complex relationship that I am trying to make work with
I have a fairly complex query where I am filtering results with a LIKE
I have a fairly complex WordPress + bbPress installation and I would like to

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.