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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:23:32+00:00 2026-06-07T12:23:32+00:00

I have implemented a thread in android which refresh the fragment (some text list

  • 0

I have implemented a thread in android which refresh the fragment (some text list ) for every 1 second .

its giving the runtime error while calling the fragment method at thread ,. here is my code

public class RunThreadExtended extends Activity implements Runnable
{
public void run() {

 while(true)
 {  try {
    Thread.sleep(1000);
    AndroidListFragmentActivity.strup++;
    MyListFragment1 fragmentB = (MyListFragment1)getFragmentManager().findFragmentById(R.id.fragment1);
    fragmentB.updatefrag();
} catch (InterruptedException e) {
    e.printStackTrace();
}
  }}}

If I call the fragment method from Mainactivity everything works from , since I need to refresh the thread for every 5 seconds in the backgroud I have implemented like this , but its not working ..pls suggest solution …

  • 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-07T12:23:33+00:00Added an answer on June 7, 2026 at 12:23 pm

    I think you have to do the refreshing in

    yourActivity.runOnUiThread(new Runnable() {
    public void run()   { /* here */ });
    

    Or via a Handler, or via a post() or in an AsyncTask‘s onProgress()

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

Sidebar

Related Questions

I have an app in android that in a different thread from the UI(which
I am using some threads in java android, I have a class which implements
I have a class which extends Application in an Android tabHost app. In the
I have an android activity and a service implemented using aidl. Works like a
I have some questions about android ui api. Give a example, that I want
Sorry about the in-concise title. I have an Android app in which I draw
I have a background thread loading data which I want to display in an
i have a question. I'm developing an Android Application. Actually, i have a thread
Using android-support-v4.jar and FragmentActivity (no fragments at this point) I have an AsyncTaskLoader which
I have implemented a basic threaded producer-consumer (thread 1 = producer, thread 2 =

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.