android之调用摄像头

本文详细介绍了在Android应用中如何调用摄像头进行拍照,并且对拍摄的照片进行裁剪显示在ImageView中。通过创建File对象存储图片,利用Intent触发相机应用,捕获结果后进行照片裁剪,最后在onActivityResult中解析图片并显示。
摘要由CSDN通过智能技术生成

android之调用摄像头

一,调用摄像头拍照

很多应用程序都可能会使用到调用摄像头拍照的功能,比如说程序里需要上传一张图片
作为用户的头像,这时打开摄像头拍张照是最简单快捷的。下面就让我们通过一个例子来学
习一下,如何才能在应用程序里调用手机的摄像头进行拍照。
新建一个ChoosePicTest 项目,然后修改activity_main.xml 中的代码,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="@+id/take_photo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Take Photo" />
<ImageView
android:id="@+id/picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值