In Android is there any way to download an image file without knowing its type ahead of time? I have this AsyncTask that downloads an image and sets it to a bitmap but I don't want to force any specific extension. Instead, I was hoping to declare a set of acceptable formats then pull using just the unique filename. Any suggestions or alternatives?
public class asyncGetPhoto extends AsyncTask<Void, String, Bitmap>{
ProgressBar imageProgress;
@Override
protected void onPreExecute(){
imageProgress = (ProgressBar)findViewById(R.id.aboutusImgProgress);
imageProgress.setVisibility(View.VISIBLE);
}
@Override
protected Bitmap doInBackground(Void... arg0) {
String url = "SomeDirectory/images/image1.png"
Bitmap img = BitmapFactory.decodeStream((InputStream)new URL(url).getContent());
return img;
}
@Override
protected void onPostExecute(Bitmap img){
photo.setImageBitmap(img);
imageProgress.setVisibility(View.GONE);
}
}