[SOLVED]Error after show ProgressDialog while parsing XML

Put your problem here if it does not fit any of the other categories.

[SOLVED]Error after show ProgressDialog while parsing XML

Postby bonny » Wed Dec 10, 2008 10:58 am

Hi all!
I was trying to show a ProgressDialog while parsing a xml from a web service, but when the ProgressDialog should dismiss I receive this error:
Code: Select all
12-10 10:54:47.345: WARN/dalvikvm(1091): threadid=21: thread exiting with uncaught exception (group=0x40010e28)
12-10 10:54:47.345: ERROR/AndroidRuntime(1091): Uncaught handler: thread Thread-11 exiting due to uncaught exception
12-10 10:54:47.365: ERROR/AndroidRuntime(1091): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.os.Handler.<init>(Handler.java:111)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.widget.CursorAdapter$ChangeObserver.<init>(CursorAdapter.java:350)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.widget.CursorAdapter.init(CursorAdapter.java:112)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.widget.CursorAdapter.<init>(CursorAdapter.java:90)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.widget.ResourceCursorAdapter.<init>(ResourceCursorAdapter.java:46)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at android.widget.SimpleCursorAdapter.<init>(SimpleCursorAdapter.java:84)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at com.google.android.voipdroid.Contacts.fillContacts(Contacts.java:275)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at com.google.android.voipdroid.Contacts.access$2(Contacts.java:267)
12-10 10:54:47.365: ERROR/AndroidRuntime(1091):     at com.google.android.voipdroid.Contacts$1.run(Contacts.java:193)

This is the code I tried to run :
Code: Select all
final ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage("Please wait while loading...");
        new Thread() {
           public void run() {
//              try {
//                 sleep(1500);
//              }catch (Exception e) {
//                 Log.v("DIALOG", e.getMessage());
//              }
              XMLContact.getContacts(username, pwd);

XMLContact is the class in which I have all the methods to do http get or post to the webservice.
With parsed data I create some rows on a database, and fillContacts show rows on the screen.
Code: Select all
   private void fillContacts(Cursor contact) {
      // Create the item list

      String[] from = new String[] { ContactsDbAdapter.KEY_NAME };
      int[] to = new int[] { R.id.text1 };

      // Now create an array adapter and set it to display using our row
      SimpleCursorAdapter contactAdapter = new SimpleCursorAdapter(this,
            R.layout.contact_row, contact, from, to);

What should I do to resolve the problem?
Last edited by bonny on Wed Dec 10, 2008 11:46 am, edited 1 time in total.
Junior Developer
Junior Developer
Posts: 19
Joined: Fri Apr 11, 2008 2:08 pm


Postby bonny » Wed Dec 10, 2008 11:46 am

I solved the problem following this
Thank you!
Junior Developer
Junior Developer
Posts: 19
Joined: Fri Apr 11, 2008 2:08 pm


Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 28 guests