I made a button to take the screenshot and save into Pictures folder. I set it as being saved under the name capture.jpeg but I wanted it to be saved as such as cafe001.jpeg, cafe002.jpeg like this. Also would you please let me know how I can save it as time format.jpeg ? Thank you for your help in advance
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();
}
});
See Question&Answers more detail:os