本文介绍了着创建内螺纹的处理程序已经不叫尺蠖。prepare的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我知道有许多与此相关的问题,但我仍然感到无法说服,所以要求

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

我正在创造着内螺纹的处理程序已经不叫尺蠖。prepare当我尝试显示对话框。

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

下面是我的code ...

Here is my code...

//该方法是从一个不同的方法称为基于一些条件是inturn称为上点击按钮

//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();
 }

现在在此之前actity被调用我试图显示一个对话框。我想地方,只是打电话意图之前。

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

推荐答案

您不能显示来自一个子线程的对话框。
一个对话框,只能从UI线程/主线程中显示。

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

从子线程里面试试这个

runOnUiThread(new Runnable() {

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

        }
    });

这篇关于着创建内螺纹的处理程序已经不叫尺蠖。prepare的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:26