Android Camera technology (1)

Source: Internet
Author: User

Android Camera technology (1)

 

The Android SDK supports operations on built-in cameras of Android devices. You can operate multiple cameras (mainly pre-cameras and post-cameras) Starting with Android2.3 ). You can take photos and videos through a camera.

Quick photo taking (simple photo taking) directly view code

View:

 


Java:

 

 

 

 

Public class MainActivity extends Activity implements View. onClickListener {private ImageView iv = null; @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); setContentView (R. layout. activity_main); Button btn = (Button) findViewById (R. id. btn); btn. setOnClickListener (this); iv = (ImageView) findViewById (R. id. iv) ;}@ Override protected void onActivityResult (int requestCode, int resultCode, Intent data) {super. onActivityResult (requestCode, resultCode, data); if (requestCode = 1) {if (resultCode = Activity. RESULT_ OK) {// determine if the photo button Bitmap cameraBitmap = (Bitmap) data is clicked. getExtras (). get (data); iv. setImageBitmap (cameraBitmap); // display the image (not saved locally) }}@ Override public void onClick (View v) {Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE); // you can call the camera startActivityForResult (intent, 1) with only these two lines of code );}}

The same as the video recorded above

 

 

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.