Android Development-Call the system camera to take photos should pay attention to the points.

Source: Internet
Author: User

(a) Call camera to save to the specified folder, Intent.putextra (file) to save the captured photos directly to the folder

However, this method can not be used to shoot video, the same in the camera, if the path is passed, the screen card will be dead, while the incoming path will have an empty file, the file name is correct, but no data, and in the callback function Onactivityresult data is not empty, The path name that will be passed in for you. Therefore, it is best not to pass in the storage path when using intent to call the camera, otherwise there will be different problems on different machines, so we can find the files by the default given path.

(b) as follows: Photo shoot

             Intent intent=new Intent ();              Specifies the ACTION             intent.setaction (mediastore.action_image_capture) to turn on the system camera;           
Intent.addcategory (Intent.category_default); Create a file based on the address file file=new files (file_path); Convert the file address to URI format URI uri=uri.fromfile (file); Set The storage address Intent.putextra (Mediastore.extra_output, Uri) of the picture file after the system camera takes the photo;

Video:

            



if (file.exists ()) {
File.delete ();
}




Android Development-Call the system camera to take photos should pay attention to the points.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.