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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:07:29+00:00 2026-05-27T02:07:29+00:00

Please help with this error …. In the following code the get info function

  • 0

Please help with this error …. In the following code the get info function works correctly but it gives an error saying the thread caught an exception at exiting…. I am trying to use a tab host and the first tab page is the following… In this i show a progress dialog until i get my data and then show it in a list view

public class History extends Activity implements OnItemClickListener
{
/** Called when the activity is first created. */
ListView list;

//LIST OF ARRAY STRINGS WHICH WILL SERVE AS LIST ITEMS
ArrayList<String> listItems;

//DEFINING STRING ADAPTER WHICH WILL HANDLE DATA OF LISTVIEW
ArrayAdapter<String> adapter;
private String resDriver,resPassenger,ID;
private ProgressDialog dialog;
ArrayList<HashMap<String, Object>> listInfo = new ArrayList<HashMap<String, Object>>();
HashMap<String, Object> item;
JSONObject jDriver;
//JSONObject jPassenger;

// Make strings for logging
private final String TAG = this.getClass().getSimpleName();
private final String RESTORE = ", can restore state";
private final String state = "Home Screen taking care of all the tabs";
@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Intent loginIntent = getIntent();
    ID = loginIntent.getStringExtra("ID");
    listItems = new ArrayList<String>();
    Log.i(TAG, "Started view active rides");
    setContentView(R.layout.searchresults);
    list = (ListView)findViewById(R.id.ListView01);
    list.setOnItemClickListener(this);
    adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,listItems);

    list.setAdapter(adapter);
    getInfo();
}

The function getInfo is used to start a thread which shows a dialog box and starts a http request to get some data …

public void getInfo(){
    GetInfoThread checkUpdate = new GetInfoThread();
    checkUpdate.start();
    dialog = ProgressDialog.show(History.this, "Retrieving Info","Please Wait ...", true);
}

private class GetInfoThread extends Thread
{
    public void run() {
        jDriver = new JSONObject();
        try {
            jDriver.put("ID", ID);
            jDriver.put("task", "GET DATES");

        } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        listItems = new ArrayList<String>();
        Log.i(TAG,"Sending data for the driver rides");
        resDriver = HTTPPoster.sendJson(jDriver,"http://dsadsada"); // Any Server URL

        JSONObject driver;
        try {
            driver = new JSONObject(resDriver);
            Log.i(TAG,"Recieved Driver details");

                    listItems.add(array[0]);
                    handler.sendEmptyMessage(0);
                }
            }
        } catch (JSONException e) {
        // TODO Auto-generated catch block
            listItems.add("No driver rides created");
            handler.sendEmptyMessage(0);
        }

    }

    private Handler handler = new Handler() {
        @Override
       public void handleMessage(Message msg) {
           dialog.dismiss();
           Log.i(TAG,"hello 123");
           adapter.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-27T02:07:30+00:00Added an answer on May 27, 2026 at 2:07 am

    I am not sure exactly what is causing your error but I suspect it has to do with UI changes not running on the actual UI thread. In Android there is a class called AsyncTask that will do the threading for you and handle the passing of data between the background thread an the UI thread. I would suggest rewriting your code to utilize the AsyncTask class.

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

Sidebar

Related Questions

i'm using QT Creator 1.3.1 and trying to compile, but get this error... please
Please help me get to the bottom of this...the only file that this error
how to add checkbox values in mysql database?Please help I always get this error
This error is driving me nuts. Please help. The code compiles in gcc in
Hi Guys can you please help me with this error? What is it? Server
Please help! I have been grappling with this error for days and I cannot
can someone please help me. why does this return an error: Dim stuff As
Please help me with this code - I am basically going through a book
Please help me with this WCF error....How do I handle these builtin classes for
Please help me figure this out. I've tried so many combinations but nothing seems

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.