cant create handler inside thread that has not called looper.prepare

Note : I know there are many questions related to this, but still I am not convince, so asking.

I am getting cant create handler inside thread that has not called looper.prepare when I try to show the dialog.

Here is my code...

//this method is called from a different method based on some condition which is inturn called on click a button

 private void download() {
    thread = new Thread() {
     public void run() {
    /**** Downloads each tour's Tour.plist file ****/
            try {
                // do many heavy operations here, like download, 
                //calling web webvice and starting another activity

               This comes at the end

                Intent toAudio = new Intent(TourDescription.this,Audio.class);
                startActivity(toAudio);
         } catch (Exception e) {
       }  

       }
    }; 
    thread.start();
 }

Now before this actity gets called I am trying to show a dialog. I am trying to place that just before calling Intent.

Can any body please tell me how to do this, as I am not understanding how to solve this

Answers


you cannot show a dialog from a child thread. A dialog can only be showed from within the UI thread/main Thread.

try this from inside the child thread

runOnUiThread(new Runnable() {

        @Override
        public void run() {
            // TODO show dialog....

        }
    });

Need Your Help

Multiple Master-Details with root view - iOS

ios master-detail uistoryboardsegue rootview

I have a master-detail application. The master scene is a tableview and the detail is a simple view controller with some text.

TSQL in the Command object

.net sql-server vb.net tsql

Please see the sub routine below:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.