You are dismissing dialog in a Runnable, thats why you have exception.

Try do it in UI Thread, I mean obtain message and send it to Handler.

On 20 Лис, 12:45, PaulJ <pjablonsk...@gmail.com> wrote:
> Hi there brainiacs,
>
> I'd like to ask about how to proper handle progressDialog in Thread,
> since gettings the error from subject.
>
> My code:
>
>                                                                 Thread 
> logThread = new Thread()
>                                                                 {
>                                                                         
> String result = new String();
>
>                                                                         
> @Override
>                                                                         
> public void run()
>                                                                         {
>                                                                               
>   Looper.prepare();
>
>                                                                               
>   try
>                                                                               
>   {
>                                                                               
>           result = ofsomesomeoperation();
>                                                                               
>   }
>                                                                               
>   catch (NoSuchAlgorithmException e)
>                                                                               
>   {
>
>                                                                               
>   }
>                                                                               
>   catch (IOException e)
>                                                                               
>   {
>
>                                                                               
>   }
>
>                                                                               
>   logHandler.post(new Runnable()
>                                                                               
>   {
>                                                                               
>           public void run()
>                                                                               
>           {
>                                                                               
>                   if (result.equals(something1))
>                                                                               
>                   {
>                                                                               
>                           dialogLogProg.dismiss();
>                                                                               
>                           showDialog(dialog_something1);
>                                                                               
>                   }
>                                                                               
>                   else if (result.equals(something2))
>                                                                               
>                   {
>                                                                               
>                           dialogLogProg.dismiss();
>                                                                               
>                           showDialog(something2);
>                                                                               
>                   }
>                                                                               
>                   else
>                                                                               
>                   {
>                                                                               
>                           dialogLogProg.dismiss();
>                                                                               
>                           Intent newint = new Intent(Example.this,
> NewInt.class);
>                                                                               
>                           startActivity(newint);
>                                                                               
>                           Example.this.finish();
>                                                                               
>                   }
>                                                                               
>           }
>                                                                               
>   });
>                                                                               
>   Looper.loop();
>                                                                         }
>                                                                 };
>                                                                 
> logThread.start();
>
> Problem occurs when a dialog progress appears and I change my phone
> orientation, it freezes and crashes.
>
> Greetings.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to