我做了一个按钮来截取屏幕截图并保存到图片文件夹中。我将它设置为以名称 capture.jpeg 保存,但我希望它像这样保存,例如 cafe001.jpeg、cafe002.jpeg。另外请告诉我如何将其保存为时间 format.jpeg ?提前谢谢你的帮助
container = (LinearLayout) findViewById(R.id.LinearLayout1);
Button captureButton = (Button) findViewById(R.id.captureButton);
captureButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
container.buildDrawingCache();
Bitmap captureView = container.getDrawingCache();
FileOutputStream fos;
try {
fos = new FileOutputStream(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES).toString() + "capture.jpeg");
captureView.compress(Bitmap.CompressFormat.JPEG, 100, fos);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Toast.makeText(getApplicationContext(),
"Captured under Pictures drectory", Toast.LENGTH_LONG)
.show();
}
});