在实际的应用程序里我们可能会使用到摄像头比如我们平时使用的淘宝,评价时可以拍照上传,还有平时使用的美颜相机。我们在自己的应用程序中也可以实现调用摄像头的功能。
一、调用摄像头实现拍照功能
启动摄像头其实很简单,步骤如下。
Intent intent = new Intent();
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
startActivity(intent);
示例
1、布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/btn_start_camera"