从手机获取图片让WebView支持本地上传图片
一,从本地获取相册中的图片,并获取图片的URI
Intent intent =newIntent(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent, intentType);
@Override
protectedvoid onActivityResult(int requestCode,int resultCode,Intent data){
if(requestCode == FILECHOOSER_RESULTCODE){
if(null== mUploadMessage){
return;
}
Uri result = data ==null|| resultCode != RESULT_OK ?null: data.getData();
if(result ==null){
mUploadMessage =null;
return;
}
String filename = getRealPathFromURI(result);
if(filename !=null){
result =Uri.fromFile(newFile(filename));
}
mUploadMessage.onReceiveValue(result);
mUploadMessage =null;
}
}
content://com.android.providers.media.documents/document/image:8191
",然后通过Uri uri= data.getData();所拿到的uri却变成了"
content://com.android.providers.media.documents/document/image%3A8191
",image后边的冒号自动转义了,而且uri也跟一般所见"
content://media/external/images/media/63
"这样的uri格式不同,网上查找后终于找到解决方法:
Intent i =newIntent(Intent.ACTION_PICK,MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(Intent.createChooser( i,"选择图片"),WebViewActivity.FILECHOOSER_RESULTCODE );
从手机获取图片让WebView支持本地上传图片的更多相关文章
- [转]微信小程序开发之从相册获取图片 使用相机拍照 本地图片上传
本文转自:http://blog.csdn.net/qq_31383345/article/details/53014610 今天遇到微信小程序的用户头像设置功能,做笔记. 先上gif: 再上代码: ...
- 微信小程序开发之从相册获取图片 使用相机拍照 本地图片上传
1.index.wxml <!--index.wxml--> <button style="margin:30rpx;" bindtap="choose ...
- 从URL获取图片并保存到本地
/// <summary> /// HttpWebRequest Property /// </summary> /// <param name="fileNa ...
- Android获取本地相册图片、拍照获取图片
需求:从本地相册找图片,或通过调用系统相机拍照得到图片. 容易出错的地方: 1,当我们指定了照片的uri路径,我们就不能通过data.getData();来获取uri,而应该直接拿到uri(用全局变量 ...
- php获取网页中图片并保存到本地
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: save_img("http://www.jbxue.com" ?>
- php获取网页中图片并保存到本地的代码
php获取网页中图片并保存到本地的代码,将网页中图片保存本地文件夹: <?php /** * 获取网页中图片,并保存至本地 * by www.jbxue.com */ header(" ...
- iOS 根据图片URL从本地相册获取图片
最近做一个聊天的项目,需要发送图片后读取本地图片显示到列表里.刚开始的时候,天真的认为可以用SDWebImage直接加载,然后并不能行. 于是在网上搜了搜,如何根据从相册获取的UIImagePicke ...
- iOS开发——打开手机相册,获取图片
1.添加代理UIImagePickerControllerDelegate 2.设置点击跳转事件 - (IBAction)picButton:(UIButton *)sender { NSLog(@& ...
- iOS图片存在本地、再从本地获取图片
图片存在本地.再从本地获取图片 //将图片保存到本地 + (void)SaveImageToLocal:(UIImage*)image Keys:(NSString*)key { NSUser ...
随机推荐
- 如何让python程序运行得更快
原则1:不优化 原则2:不要优化那些不重要的部分(否则会降低可读性) 解决方案: 1. 使用函数,局部变量比全局变量快很多.尽量使用函数,如main() 2. 有选择性的消除属性访问. 如多用 fro ...
- Citrix 服务器虚拟化之五 Xenserver配置存储
Citrix 服务器虚拟化之五 Xenserver配置存储 XenServer中定义了一个容器称为存储库(SR)来描述一个特定的存储目标存储虚拟磁盘映像(VDI). VDI是一个的磁盘抽象,包含一个 ...
- .NET单元测试
原文链接:http://www.cnblogs.com/edisonchou/p/5467573.html
- C API 连接MYSQL
#include <iostream> #include <mysql.h> #include <string> #include <assert.h> ...
- spring注解注入
@Autowired public void setUserDAO(UserDAO userDAO) { this.userDAO = userDAO; } @Test public void tes ...
- 快速同步GitHub代码库
因伟大的墙的存在,github下载速度奇慢, 简单办法,在csdn code建一个账号,然后创建工程的时候选择导入模式, 填入github的项目git URL. 然后.. 从csdn的code下载就快 ...
- nyoj 68 三点顺序
点击打开链接 三点顺序 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 现在给你不共线的三个点A,B,C的坐标,它们一定能组成一个三角形,现在让你判断A,B,C是顺时针给 ...
- (medium)LeetCode 230.Kth Smallest Element in a BST
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Not ...
- LayoutInflater.Factory的夜间模式
自定义实现个Factory,可以用来解析自定义的属性.public interface Factory { /** * Hook you can supply that is called when ...
- hbase的regionserver宕机
错误日志: regionserver.HRegionServer: Failed deleting my ephemeral node zookeeper.RecoverableZooKeeper: ...