Pro. Android media-call the built-in camera

Source: Internet
Author: User

 

The built-in camera program defines the following intent filter in manifest

XML Code
 
  1. <Intent-filter>
  2. <Action Android: Name = "android. Media. Action. image_capture"/>
  3. <Category Android: Name = "android. Intent. Category. Default"/>
  4. </Intent-filter>
<Intent-filter> <action Android: Name = "android. media. action. image_capture "/> <category Android: Name =" android. intent. category. default "/> </intent-filter>

 

So you only need to start it with the corresponding intent.

 

The following Android. provider. mediastore. action_image_capture = "android. Media. Action. image_capture ";

 

Java code
 
  1. Public class cameraintent extends activity {
  2. Final Static int camera_result = 0;
  3. Imageview mimagevview;
  4. @ Override
  5. Protected void oncreate (bundle savedinstancestate ){
  6. Super. oncreate (savedinstancestate );
  7. Setcontentview (R. layout. Contents );
  8. Intent I = new intent (Android. provider. mediastore. action_image_capture );
  9. Startactivityforresult (I, camera_result );
  10. }
  11. @ Override
  12. Protected void onactivityresult (INT requestcode, int resultcode, intent data ){
  13. Super. onactivityresult (requestcode, resultcode, data );
  14. If (resultcode = result_ OK ){
  15. // Get extras from the intent
  16. Bundle extra = data. getextras ();
  17. // Get the returned image from the extras
  18. Bitmap B = (Bitmap) Extra. Get ("data ");
  19. Mimagevview = (imageview) findviewbyid (R. Id. returnedimageview );
  20. Mimagevview. setimagebitmap (B );
  21. }
  22. }
  23. }
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.