android调用系统自带的文件管理程序选择文件

移动开发 码拜 8年前 (2016-09-20) 2711次浏览
需求是在上传文件时,我们要选择SD卡中或手机中的文件;
现在想通过点击上传时调用系统自带的文件管理器选择文件;
在onActivityResult函数中监听返回的文件集合,请求高手们教一下小弟怎么样调用系统的文件夹
本人现在是这样写都没有作用,只能在图库中选择
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType(“file/”);
//intent.setType(“*/*”);
intent.addCategory(Intent.CATEGORY_OPENABLE);
try {
startActivityForResult(Intent.createChooser(intent, “请选择一个要上传的文件”),
1);
} catch (android.content.ActivityNotFoundException ex) {
// Potentially direct the user to the Market with a Dialog
Toast.makeText(this, “请安装文件管理器”, Toast.LENGTH_SHORT)
.show();
}
setType两个都试了都不行。
解决方案

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明android调用系统自带的文件管理程序选择文件
喜欢 (0)
[1034331897@qq.com]
分享 (0)