Re: [android-developers] Re: Creating dialogs from a thread

2010-01-22 Thread Android Development
You can also spawn an AsyncTask from the UI thread. Whenever it needs to show a dialog, this task can call publishProgress() method..that automatically runs on the UI Thread and the dialog can be shown in the onProgressUpdate method. On Fri, Jan 22, 2010 at 3:41 AM, Kevin Duffey

[android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Dirk Vranckaert
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

Re: [android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread TreKing
On Thu, Jan 21, 2010 at 1:47 PM, Dirk Vranckaert dirkvrancka...@gmail.comwrote: I certainly will try it out later this evening (studying for my certification right now) Good luck! but is there any more detailed/advanced explanation about why I can't run a bunch of code in a thread and at

[android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Dirk Vranckaert
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

[android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Streets Of Boston
Dirk, You cannot create UI elements in threads that don't have a message- looper themselves. I usually do this. Call the 'post' (or 'postDelayed') method. In your example, I assume that the method getEpisodes() is part of a Thread instances that is defined as a non-static inner (anonymous)

Re: [android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Kevin Duffey
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,

Re: [android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread TreKing
On Thu, Jan 21, 2010 at 3:30 PM, Dirk Vranckaert dirkvrancka...@gmail.comwrote: It seems your solution does not work either. Um ... it should, I've used this technique repeatedly. Can you post the code you're using? As long as I'm doing it in a thread it doesn't work. Well, it depends on

[android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Streets Of Boston
Note that 'post' and 'runOnUiThread' takes a Runnable and it should *not* be a Thread (although that implements Runnable as well)! (Mis) using a Thread for this is not good. Just use a Runnable. Create a new instance of a Runnable and implement its 'public void run ()' method (see my example code

Re: [android-developers] Re: Creating dialogs from a thread

2010-01-21 Thread Kevin Duffey
Ah yes Streets.. that was what I was missing.. been a while since I dealt with UI threads. It's not that you have to run a thread on the UI.. you run a Runnable. The Runnable just defines run() method.. I forget now but I think basically it allows the UI thread to just call run() on your Runnable