I am new to Android development. I have been working on Swing and SWT for several years. Both Swing and SWT have strips for executing code in synchronization of user interface and async threads. A typical use makes it take some time to consume personnel in a single thread, and then displays the result in an asynchronous user interface thread.
So my question is, is there a similar strat in Android? Here is my code. The runnable parameter is some time consuming code. This method displays a wait dialog at runtime, then EXPECT to show Toast after it completes. But Toast needs to be shown in the user interface thread. So how to do this?
public static void showWaitingDialog(final Activity parent, final Runnable runnable, String msg) { if (StringUtils.isEmpty(msg)) { msg = "processing..."; } final ProgressDialog waitingDialog = ProgressDialog.show(parent, "Please Wait...", msg, true);
And are there any words about the Android Android interface? For example, this is Thread-Safe, how a thread works together, and so on. Many thanks!
android android-asynctask ui-thread
Deepnightight
source share