JUnit test-methods in the instrumentation test-case classes always run in
another thread than the main UI thread. I run both indiviual test-cases and
test-suites (that execute lists of test-cases) and test-methods are always
called in a different thread than the background thread.
I read this in your original question: "*... This method call (internally)
launches an AsyncTask ...*". I ran into a problem and this may be related to
your issue:
You have to *create the first AsyncTask of your (test-)process in the main
UI thread*. If you don't do this, and the (first) AsyncTask is created in a
non-UI thread (e.g. during a testXXXX() method), weird stuff can happen. In
other words: Be sure that the VM loads the AsyncTask *class* in the main UI
thread. From then on, you can create and execute AsynTasks in any thread.
E.g in your first test's setup or the first testXXXXX() method:
...
runTestOnUIThread(new Runnable() {
public void run() {
new AsyncTask(); // just create one and let it go; doing this makes
sure that the class loads in the main UI thread.
}
}
...
... // now you're free to create and execute AsyncTasks (directly or
through other method calls).
Maybe this problem is related to the one you see.
--
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