【发布时间】:2014-10-29 23:34:04
【问题描述】:
我的情况如下:我正在将数组列表中的多个位图保存到设备 SD 卡中的特定文件夹中(成功),但是,保存的文件 - 单击时会提示来自手机的消息,说明: “无法找到执行此操作的应用程序。”该文件的文件大小与保存的位图图像的大小成正比,所以我有点困惑,因为设备打开图像文件没有问题,但无法打开(或识别)这些为媒体文件。
问题:什么会导致保存的图像文件(假设我已正确保存)在设备中表现出这种类型的行为,我应该如何解决这个问题?
额外:文件的缩略图是系统提供的两张纸叠放的缩略图。数组列表正在从一个活动传递到提供所提供方法的当前活动。
这是调用将文件保存到指定文件夹/filesdestination的方法:
private void saveImages(){
// to retrieve bitmaps
ArrayList<Bitmap> images = getIntent().getParcelableArrayListExtra("images key");
//to retrieve bitmaps and save in specific order, while also naming them in that order
int loopVal = 0;
int postVal = 9;
while ( loopVal < 9) {
Bitmap Image = images.get(loopVal);
try {
String filedestination = new String(Environment.getExternalStorageDirectory() + "/filedestination");
String timeStamp = new SimpleDateFormat("ddMMyyyy_HHmm").format(new Date());
File file = new File(filedestination, postVal + ".post_order" + ".jpg" + timeStamp);
File picfile = file;
FileOutputStream fos = new FileOutputStream(picfile);
Image.compress(Bitmap.CompressFormat.PNG, 100, fos);
fos.close();
} catch (Throwable e) {
e.printStackTrace();
}
postVal--;
loopVal++;
}
}
任何见解将不胜感激,
-卢卡斯
【问题讨论】:
标签: android arrays arraylist bitmap save