setDateAndType setDate setType
来源:互联网 发布:程序最小公倍数算法 编辑:程序博客网 时间:2024/06/04 19:20
遇到个这样的问题,就是吃了没马上看源码的亏,想当然的以为setDateAndType拆开来应该也能用。
拍照和从相册选择图片剪切时由于拍照的时候有路径传回,就需要判断。
懒人的懒办法就出来了,拆setDateAndType,自己还挺开心的。
接着这一块的功能就不能用了。找半天......................................................
public static Intent getCropImageIntent(Uri photoUri) {
Intent intent = null;
if (photoUri !=null) {
intent = new Intent("com.android.camera.action.CROP");
intent.setData(photoUri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
}else {
intent = new Intent(Intent.ACTION_GET_CONTENT, null);
}
intent.setType("image/*");
// crop=true 设置在开启的Intent中显示的VIEW可裁剪
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true)
return intent;
}
*************************************************************************************************************************************
逐渐定位到问题所在,然后就骂街了。。
这几个set方法在源码当中是这样的:
public Intent setData(Uri data) { mData = data; mType = null; return this;}
public Intent setType(String type) { mData = null; mType = type; return this;}
public Intent setDataAndType(Uri data, String type) { mData = data; mType = type; return this; }
public static Intent getCropImageIntent(Uri photoUri) {
Intent intent = null;
if (photoUri !=null) {
intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(photoUri, "image/*");
intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
}else {
intent = new Intent(Intent.ACTION_GET_CONTENT, null);
intent.setType("image/*");
}
// crop=true 设置在开启的Intent中显示的VIEW可裁剪
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 80);
intent.putExtra("outputY", 80);
intent.putExtra("return-data", true);
return intent;
}
留个记忆,重新做人- setDateAndType setDate setType
- PreparedStatement.SetDate
- setdate.c
- PreparedStatement.SetDate()
- PreparedStatement.SetDate
- PreparedStatement.SetDate
- android打开各种文件setDateAndType
- SetType,a easy problem
- PreparedStatement.setDate添加时间
- PreparedStatement.setDate添加时间
- javascript当中的setDate()
- android intent.setDate方法
- setTimeStamp()与setDate()区别
- HIbernate中Query.setDate()
- 构造函数和setdate
- setTimeStamp()与setDate()区别
- PreparedStatement setDate() 和setTimestamp
- setTimeStamp()与setDate()区别
- 二维数组的定义和引用
- 多线程(三)
- EditText插入图片并存取
- Zookeeper 集群 单一节点 启动失败
- 介词短语
- setDateAndType setDate setType
- 升级macOS系统版本后pod命令无效的问题
- 2 unit 8
- 浅析HTTPS中间人攻击与证书校验
- PHP内置函数array_reverse、array_reduce、call_user_func和call_user_func_array
- ajax数据回显同步
- 第十四周项目二 二叉树排序树中查找的路径
- 5个常用的MySQL数据库管理工具
- hadoop常用命令