Did you create a 2nd thread with the run() method having the call to the
dialog.. and then queue that thread onto the UI thread? It should work.

I am not sure why you need to do the call to the dialog on the UI Thread
entirely.. I've done a lot of Swing stuff where the UI thread was event
driven, and I always understood that anything that takes more than a minute
amount of time you put in a thread and queued the thread as an event on the
UI thread. But in my learning exercises, in the main activity, I've done the
showDialog call (forget the name of it) and not in a separate thread and it
showed up. The only thing I can think of is that because you are doing work
in another thread, you're outside the main UI thread and thus you need to
get back inside the UI Thread for it to access the screen.. and thus you
have to wrap it in that 2nd thread and queue it for it to work.


On Thu, Jan 21, 2010 at 1:30 PM, Dirk Vranckaert
<[email protected]>wrote:

> It seems your solution does not work either. As long as I'm doing it
> in a thread it doesn't work.
>
> Altough what I tried next was setting the error message for the user
> in my catch clause. And right after the thread finished I handled the
> showing of the errors based on wheater some error message was set or
> not!
>
> Thx for your help! (If you get me some advanced explanation on why
> dialogs cannot be created from within a thread plz let me know!)
>
> On 21 jan, 20:47, Dirk Vranckaert <[email protected]> wrote:
> > I certainly will try it out later this evening (studying for my
> > certification right now) but is there any more detailed/advanced
> > explanation about why I can't run a bunch of code in a thread and at
> > the end of the thread start a dialog? Why I have to start a nested
> > thread with just the dialog creation? :s Still don't really get the
> > reason why...
> >
> > Anyway thx in advance for giving me a possible working solution, and
> > I'll certainly keep you informed if it did the job for me (later this
> > evening).
> >
> > On 21 jan, 19:47, TreKing <[email protected]> wrote:
> >
> > > On Thu, Jan 21, 2010 at 12:28 PM, Dirk Vranckaert
> > > <[email protected]>wrote:
> >
> > > > So if I understand you correct I should run two nested threads to
> show
> > > > the dialog?
> >
> > > Yup. So instead of showDialog(int) in the thread, do
> > > runOnUiThread(someThread); where someThread just calls showDialog(int)
> in
> > > it's run method.
> >
> > > Yes, it's annoying and messy, but you can't do UI related operations in
> > > separate threads, so there you go.
> >
> > >
> -------------------------------------------------------------------------------------------------
> > > TreKing - Chicago transit tracking app for Android-powered
> deviceshttp://sites.google.com/site/rezmobileapps/treking
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to