In my application the user can upload a photo to server by either choosing an existing one or taking a new one. When taking a new one I have the following code:
// Take a new photo
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File cameraFolder;
if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
cameraFolder = new File(android.os.Environment.getExternalStorageDirectory(), "images/");
} else {
cameraFolder = getCacheDir();
}
if (!cameraFolder.exists()) {
cameraFolder.mkdirs();
}
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd'T'HHmmss");
String timeStamp = dateFormat.format(new Date());
String imageFileName = "picture_" + timeStamp + ".jpg";
File photo = new File(Environment.getExternalStorageDirectory(), "images/" + imageFileName);
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
pictureUri = Uri.fromFile(photo);
startActivityForResult(takePictureIntent, ACTION_REQUEST_CAMERA);
The problem with above code is that the photo is not saved to the gallery which I need. How do I get the user to take a photo and have it saved and submit to my server?