Okay, it might be a noob question, but I couldnt find anything to help me. I am loading an BitMap on a ImageView as an Async task, in this class:
class MyNetworkTask extends AsyncTask<URL, Void, Bitmap> {
ImageView tIV;
public MyNetworkTask(ImageView iv){
tIV = iv;
}
@Override
protected Bitmap doInBackground(URL... urls) {
Bitmap networkBitmap = null;
URL networkUrl = urls[0]; //Load the first element
try {
networkBitmap = BitmapFactory.decodeStream(
networkUrl.openConnection().getInputStream());
} catch (IOException e) {
e.printStackTrace();
}
return networkBitmap;
}
@Override
protected void onPostExecute(Bitmap result) {
tIV.setImageBitmap(result);
}
And thats how I call it from my Activity:
new MyNetworkTask(myImageView).execute(photo_url);
But that is going to be async, right? Which means that if right after in my Activity I try to use the BitMap, it will be null.
Is there a loop like a "do when??" that waits for this BitMap, and than do something?
Or is there a way of handling a callback from that Async Class?