I am using AsyncTask to get data from a server and want to show a Screen while it is loading like this:
private class GetListTask extends AsyncTask {
protected void onPreExecute() {
Intent intent = new Intent();
intent.setClass(Start.this, Wait.class);
startActivity(intent);
}
protected Bitmap doInBackground(Object... args) {
//here i get the data from the server
d = getImageFromURL(Start.valuesArray[Integer.parseInt(Value)][7]);
Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
double ratio = (double) bitmap.getWidth() / (double) bitmap.getHeight();
Bitmap scaled = Bitmap.createScaledBitmap(bitmap, width, (int) (width / ratio), true);
return scaled;
}
protected void onPostExecute(Object objResult) {
if (objResult != null && objResult instanceof Bitmap) {
Bitmap result = (Bitmap) objResult;
im.setImageBitmap(result);
}
}
}
Now, in onPostExecute() I need to hide this “Wait” Screen again, but how do I do that?
Thanks for helping!
instead of starting a different activity you can show your image in a PopupDialog and close it in onPostExecute