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