This is my camera relative to call the relevant code, this is OK:
imageFilePath = Environment.getExternalStorageDirectory()
.toString()+"/DCIM/mytest" + File.separator+timeStamp +".jpg";
File imageFile = new File(imageFilePath);
Uri imageFileUri = Uri.fromFile(imageFile);
Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
startActivityForResult(i, CAMERA_RESULT);
This is my camera call:
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
imageFilePath = Environment.getExternalStorageDirectory()
.toString()+"/DCIM/mytest" +File.separator+timeStamp +".mp4";
File imageFile = new File(imageFilePath);
Uri imageFileUri = Uri.fromFile(imageFile);
Intent i = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri);
i.putExtra(android.provider.MediaStore.EXTRA_VIDEO_QUALITY, 1);
startActivityForResult(i, VIDEO_RESULT);
But if I set the path of the camera is set to the wrong example (originally "VIDEO_" should be in the back of the amount File.separator):
imageFilePath = Environment.getExternalStorageDirectory()
.toString()+"/DCIM/mytest" + "VIDEO_"+File.separator+timeStamp +".mp4";
then the video file will be saved to the default path DCIM / Camera path, this time, the camera is working properly · · do not know why, oh? Seeking advice ah ~ ~
------ Solution ----------------------------------- ---------
about storage to the default
imageFilePath = Environment.getExternalStorageDirectory ()
. toString () + "/ DCIM / mytest" + "VIDEO_" + File.separator + timeStamp + ". mp4";
File imageFile = new File (imageFilePath);
Print this imageFile what you look at the absolute path
possible path error System Camera will adjust this path you
In fact, there is a problem: Add me to judge whether there is a file path, and then build the path, but this does not seem to amount, I use
if (imageFile.exists ()) imageFile.mkdirs ();
· · · I've always wondered, so later on to establish a direct manual / DCIM / mytest / folder path of the · · meet a lot of small problems, no experience, do not know ah · · · ·
not understand your judgment here and back mkdirs is doing what should be there to delete it? Then start recording was so logical, right
------ For reference only ---------------------------- -----------
fact, there is a problem: Add me to judge whether there is a file path, and then build the path, but this does not seem to amount, I use
if (imageFile.exists ()) imageFile.mkdirs ();
· · · I've always wondered, so later on to establish a direct manual / DCIM / mytest / folder path of the · · meet a lot of small problems, no experience, do not know ah · · · ·
------ For reference only ---------------------------------- -----
http://developer.android.com/training/camera/videobasics.html look may help
------ For reference only --- ------------------------------------
is if ( ! imageFile.exists ()) imageFile.mkdirs ();
if does not exist, then establish that file ·
------ For reference only ---------------------- -----------------
not necessary to write path directly on the line, no need to create that file.
没有评论:
发表评论