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