Use WeakReference do get the Context of the Activity from which you are calling the DownloadImage class, ProgressBar requires the Context in its constructors 1st parameter.
public class DownloadImages extends Activity{
ProgressBar progressBar = new ProgressBar(DownloadImages.this, null, android.R.attr.progressBarStyleSmall);
public static class DownloadImage extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
private WeakReference<DownloadImages> mWeakReference;
public DownloadImage(DownloadImages downloadImages, ImageView bmImage) {
this.bmImage = bmImage;
mWeakReference= new WeakReference<DownloadImages>(downloadImages);
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
Log.e("TAG","IMAGEN CARGADA");
}
protected void onPreExecute(){
mWeakReference.get().progressBar.setVisibility(View.VISIBLE);
}
}
}
Now pass 'this' from Activity when you start the AsyncTask.