【发布时间】:2016-03-06 03:35:39
【问题描述】:
我在保存图像时遇到了文件名问题。
String fileName = currentDate + currentTime + personName;
private void saveImage()
{
View u = mView;
ScrollView z = (ScrollView) findViewById(R.id.scroll_view);
int totalHeight = z.getChildAt(0).getHeight();
int totalWidth = z.getChildAt(0).getWidth();
Bitmap b = getBitmapFromView(u, totalHeight, totalWidth);
try {
FileOutputStream fos = new FileOutputStream(fileName);
b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
MediaStore.Images.Media.insertImage(getContentResolver(), b, "Screen", "screen");
}catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
输出文件时,文件名设置为一系列数字(例如:“1457223074488”)而不是字符串。 如果有人可能有解决方案,请告诉我。
【问题讨论】:
-
什么是currentDate和currentTime?这些时间可能以毫秒为单位吗?
-
currentDate 是日期格式 mm/dd/yy,currentTime 是时间格式 HHMM