I need to parse an image from some Json and STORE it on phone gallery . I have no idea how to save pictures on SD card so I need a code for this thanks .
Try this.. realy help you
public class ImageDownloadTask extends AsyncTask {
CustomProgressBar progressDialog;
Bitmap bitmap;
Drawable drawable;
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
progressDialog = CustomProgressBar.show(UpdateActivity.this,
"Loading...", true, true);
}
@Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
URL url;
InputStream in;
BufferedInputStream buffIn;
try {
url = new URL(imageUrl);
in = url.openStream();
buffIn = new BufferedInputStream(in);
bitmap = BitmapFactory.decodeStream(buffIn);
drawable = new BitmapDrawable(bitmap);
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
if (bitmap != null)
imageViewPhoto.setBackgroundDrawable(drawable);
else
imageViewPhoto
.setBackgroundResource(R.drawable.img_default_photo);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.