Android examples for Camera:Photo
generate Timestamp Photo File Name
//package com.java2s; import android.os.Environment; import android.util.Log; import java.io.File; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static File generateTimestampPhotoFile() { File photoFile = null;/*w ww . j a v a2 s. c om*/ File outputDir = getPhotoDirectory(); if (outputDir != null) { String timeStamp = new SimpleDateFormat("yyyyMMDD_HHmmss") .format(new Date()); String photoFileName = "IMG_" + timeStamp + ".jpg"; photoFile = new File(outputDir, photoFileName); } return photoFile; } public static File getPhotoDirectory() { File outputDir = null; String externalStorageState = Environment.getExternalStorageState(); if (externalStorageState.equals(Environment.MEDIA_MOUNTED)) { File picturesDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); outputDir = new File(picturesDir, "asdf"); if (!outputDir.exists()) { if (!outputDir.mkdirs()) { Log.e("CAMERA_HELPER", "Unable to create output directory"); outputDir = null; } } } return outputDir; } }