0
我在保存图像时遇到了文件名的问题。保存位图并将其命名为输入的字符串
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?这些时间可能以毫秒为单位吗? – Francesc
currentDate是日期格式mm/dd/yy,currentTime是时间格式HHMM – hamdummy