调用系统文件管理器选择图片,调用系统裁剪AIP对图片处理,显示裁剪之后的图片
package com.pingyijinren.test; import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.ContentResolver;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView; import java.io.File;
import java.io.FileNotFoundException; public class MainActivity extends AppCompatActivity{
private Button button;
private ImageView imageView;
private Uri uri;
private File file; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); button=(Button)findViewById(R.id.button);
imageView=(ImageView)findViewById(R.id.imageView); button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
file=null;
try{
file=new File(Environment.getExternalStorageDirectory()+"/test.jpg"); if(file.exists()){
file.delete();
}
file.createNewFile(); uri= Uri.fromFile(file);
Intent intent=new Intent("android.intent.action.GET_CONTENT");
intent.setType("image/*");
startActivityForResult(intent,1);
}
catch(Exception e){}
}
});
} @Override
protected void onActivityResult(int requestCode,int resultCode,Intent data){
if(requestCode==1){
uri=data.getData();
Intent cropIntent=new Intent("com.android.camera.action.CROP");
cropIntent.setDataAndType(uri,"image/*");
cropIntent.putExtra("scale",true);
cropIntent.putExtra(MediaStore.EXTRA_OUTPUT,uri);
startActivityForResult(cropIntent,2);
}
else if(requestCode==2){
try{
Bitmap bitmap= BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
imageView.setImageBitmap(bitmap);
}
catch(Exception e){} }
}
}
调用系统文件管理器选择图片,调用系统裁剪AIP对图片处理,显示裁剪之后的图片的更多相关文章
- 安卓 通过intent调用系统文件管理器打开指定路径目录
安卓 通过intent调用系统文件管理器打开指定路径目录 转 https://blog.csdn.net/qq_34161388/article/details/78586247 当我们知道 ...
- DeepinV20系统文件管理器右键发送至为知笔记
1. 创作背景 昨天在深度系统上做了一个打开文件管理器选择文件右键发送文本至博客园的插件. 这个插件对于我自己来说是及其方便的东西,平时的学习积累,工作经验或者生活感悟,随手记下之后,就能够轻松发送出 ...
- win10 uwp 打开文件管理器选择文件
本文:让文件管理器选择文件,不是从文件管理器获得文件. 假如已经获得一些文件,那么如何从文件管理器选择这些文件? 使用方法很简单. 从网上拿图来说 打开文件夹自动选择所有文件 首先需要获得文件夹,因为 ...
- 2018-8-10-win10-uwp-打开文件管理器选择文件
title author date CreateTime categories win10 uwp 打开文件管理器选择文件 lindexi 2018-08-10 19:16:50 +0800 2018 ...
- html5图片上传时IOS和Android均显示摄像头拍照和图片选择
最近在做信开发时,发现<input type="file" />在IOS中可以拍照或从照片图库选择,而Android系统则显示资源管理器,无拍照选项,网上查找资料,改为 ...
- SpringBoot源码修炼—系统初始化器
SpringBoot源码修炼-系统初始化器 传统SSM框架与SpringBoot框架简要对比 SSM搭建流程 缺点: 耗时长 配置文件繁琐 需要找合适版本的jar包 SpringBoot搭建流程 优点 ...
- 深入剖析Classloader(二)--根类加载器,扩展类加载器与系统类加载器
原文地址:http://yhjhappy234.blog.163.com/blog/static/31632832201152555245584/?suggestedreading&wumii ...
- h5 实现调用系统拍照或者选择照片并预览
这次又来分享个好东西! 调用手机相机拍照或者是调用手机相册选择照片,这个功能在 手机端页面 或者 webApp 应该是常用到的,就拿个人或会员资料录入那块来说就已经是经常会碰到的, 每当看到这块功能的 ...
- HTML5: 实现调用系统拍照或者选择照片并预览
ylbtech-HTML5: 实现调用系统拍照或者选择照片并预览 1.返回顶部 1. <!DOCTYPE html> <html> <head> <meta ...
随机推荐
- Android开发学习——Android Studio配置SVN
一.基本配置 1. 下载这个,然后双击 安装,按下图这样选 然后 傻瓜式安装 2. 进入Android studio设置:Use Command Line Client 选择浏览到第1步你本地安装 T ...
- .net 环境下c# 通信
.net环境下通信主要掌握 通信协议(UDP&TCP). 网络抓包工具().:使用方法 点对点通信,IP组播,广播通信 c#中结构体转为字节流方式 c#结构体与c++结构体转换对应关系 开源的 ...
- t-sql的楼梯:超越基本级别6:使用案例表达式和IIF函数
t-sql的楼梯:超越基本级别6:使用案例表达式和IIF函数 源自:Stairway to T-SQL: Beyond The Basics Level 6: Using the CASE Expre ...
- Java基础知识强化98.01:Jsp和servlet有什么区别
1. Jsp和servlet有什么区别 首先你先要弄懂什么是servlet,servlet是在服务器端执行的java程序,只不过它有专门的一套规则(就是我们平常所说的api):jsp说得简单点就是用另 ...
- Custom Operators
New operators are declared at a global level using the operator keyword, and are marked with the pre ...
- 部分cocoscreator左右移动代码
cc.Class({extends: cc.Component, properties: { // 主角跳跃高度 jumpHeight: 0, // 主角跳跃持续时间 jumpDuration: 0, ...
- spring-shiro 配置
配置 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www ...
- 阿里云服务器基本搭建_错误1_Permission denied (publickey)
首先 修改这两个密码 然后重启服务器就可以了
- 使用Caliburn.Micro系列1:新建项目并引入CM
一.WPF的几个MVVM模式实现 MVVMLight:小众的平民框架,实现简单粗暴. pass:最近更新在15年 官网: http://www.mvvmlight.net/ 最近一篇内容全面的好文: ...
- 正则表达式,匹配查找函数(preg_match_all)flags参数对比
格式: int preg_match_all ( string pattern, string subject, array matches [, int flags] ) 参数 flags 选项有以 ...