Android 7.0 获取相机拍照图片
来源:互联网 发布:鸮和猫头鹰区别知乎 编辑:程序博客网 时间:2024/06/04 19:00
新建/res/xml/file_paths:
<?xml version="1.0" encoding="utf-8"?><paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="."/></paths>配置manifest文件
<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.hunuo.yohoo.provider" //com.hunuo.yohoo=包名 android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths"/></provider>修改uri和putExtra参数
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);if (cameraIntent.resolveActivity(UserManageActivity.this.getPackageManager()) != null) { filePhoto = new File(path, getTime()+".jpg"); Uri photoURI = FileProvider.getUriForFile(UserManageActivity.this, "项目包名.provider", filePhoto); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI); //Uri.fromFile(tempFile) startActivityForResult(cameraIntent, CAMERA_REQUEST_CODE);}剪切图片
private void crop(file filePhoto) {// cropImagePath = file.getAbsolutePath(); Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(getImageContentUri(filePhoto), "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 300); intent.putExtra("aspectY", 300); intent.putExtra("outputX", 300); intent.putExtra("outputY", 300); intent.putExtra("scale", true); intent.putExtra("return-data", false); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(filePhoto)); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); startActivityForResult(intent, RESULT_REQUEST_CODE); }
使用时间命名图片
public String getTime(){ long time=System.currentTimeMillis()/1000;//获取系统时间的10位的时间戳 String str=String.valueOf(time); return str;}
0 0
- Android 7.0 获取相机拍照图片
- Android_System_相机拍照获取图片
- Android调用系统相机拍照并获取图片
- Android 相机拍照获取图片并保存到指定位置。
- Android相机、相册获取图片,解决相机拍照图片被压缩模糊的情况
- android拍照获取图片
- Android开发,调用相册图片或者调用相机进行拍照获取图片
- Android启动相机拍照并返回图片
- Android 相机拍照和本地图片裁剪
- Android启动相机拍照并返回图片
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- android 调用系统相机拍照 获取原图
- Android调用相机拍照获取原始照片
- WEB技术的发展
- Spring注解@Configuration的一些东东
- PADS 地连接梅花标记和虚线问题
- javaSE_8系列博客——Java语言的特性(三)--类和对象(5)--定义方法
- SQL语句--常用(基础篇)
- Android 7.0 获取相机拍照图片
- redis学习
- Linux下如何不停止服务,清空nohup.out文件
- 谷歌浏览器调试websocket的方法
- 谈谈前端应用到的图标实体
- jQuery.extend 函数详解
- POJ 3463:Sightseeing
- 第二十五课 扩展应用程序
- 数据库优化