赞
踩
调用系统相机进行拍照的话,步骤比较简单,分为两步
<ImageView
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_centerInParent="true"
android:id="@+id/image" />
private static final int REQ_CODE = 1; private void takePhone(){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if(intent.resolveActivity(getPackageManager())!=null){//这句作用是如果没有相机则该应用不会闪退,要是不加这句则当系统没有相机应用的时候该应用会闪退 Log.e(TAG, "onClick: 手机有拍照功能" ); startActivityForResult(intent,REQ_CODE);//启动相机 } } @Override public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == REQ_CODE && resultCode == RESULT_OK){ Log.e(TAG, "onActivityResult: jinru" ); Bundle extras = data.getExtras(); Bitmap data1 = (Bitmap) extras.get("data"); addressImage.setImageBitmap(data1); Log.e(TAG, "onActivityResult: data"+data1.toString() ); } }
拍照获取原图
<uses-permission android:name="android.permission.WRITE_EXTERNAL_S
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。