urgent: How can I post a thread in a separate thread instead of main UI thread ?
in
Android Processing
•
5 months ago
Hi. sorry for posting again about what could maybe refer to the same issue (I can't be sure about this yet.)
My goal is to load images as texture in OPENGL android Application.
The issue is the thread of loading images blocks the UI main thread.
(in A2D regular render, no problem : images are loaded without affecting the main thread).
In Opengl, it doesn't.
I found this: http://developer.android.com/guide/components/processes-and-threads.html . (see worker threads). They explain how to make operation like downloading images without affecting the main thread:
simple example:
My goal is to load images as texture in OPENGL android Application.
The issue is the thread of loading images blocks the UI main thread.
(in A2D regular render, no problem : images are loaded without affecting the main thread).
In Opengl, it doesn't.
I found this: http://developer.android.com/guide/components/processes-and-threads.html . (see worker threads). They explain how to make operation like downloading images without affecting the main thread:
simple example:
public void onClick(View v) {
new Thread(new Runnable() {
public void run() {
final Bitmap bitmap = loadImageFromNetwork("http://example.com/image.png");
mImageView.post(new Runnable() {
public void run() {
mImageView.setImageBitmap(bitmap);
}
});
}
}).start();
}
mImageView.post(new Runnable() It means that the thread is handle by user interface,
and not UI Main interface.
How could I tell processing about this user interface / view to free MAIN thread
from those loading operations ?
I'm pretty in hurry, any help or advices would be really appreciated !! thanks.
pauline.
1