自分のアプリケーションをダウンロードしている間、私は、画像のダウンロードながらProgressDialog
を追加しようとしていることのためにイメージをダウンロードするのに時間がかかるダウンロード機能を持っています。 ProgressDialog
表示ProgressDialog画像は
に画像を保存するために、この私のコードを私を助けてください表示されません:。
private String saveImage(Bitmap image) {
ProgressDialog pd = new ProgressDialog(Pop.this);
pd.setMessage("Downloading ...");
pd.show();
String savedImagePath = null;
String imageFileName = "vapor"+System.currentTimeMillis()+ ".png";
File storageDir = new File(
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES)
+ "/vaporwave");
boolean success = true;
if (!storageDir.exists()) {
success = storageDir.mkdirs();
}
if (success) {
File imageFile = new File(storageDir, imageFileName);
savedImagePath = imageFile.getAbsolutePath();
try {
OutputStream fOut = new FileOutputStream(imageFile);
image.compress(Bitmap.CompressFormat.PNG, 100, fOut);
fOut.close();
} catch (Exception e) {
e.printStackTrace();
}
// Add the image to the system gallery
galleryAddPic(savedImagePath);
Toast.makeText(Pop.this, "IMAGE SAVED", Toast.LENGTH_LONG).show();
pd.dismiss();
}
return savedImagePath;
}
回答ありがとう私は 'image.compress(Bitmap.CompressFormat.PNG、100、fOut)の' Bitmap Image'に問題があります; '私は' saved savedImagePath;に問題があります。 doInBackground – pic
あなたのコードで私の答えベースを変更しました。更新されたsaveImageタスクを見てください。 – MHP
ありがとうsoo多くはうまく動作します – pic