当前位置:   article > 正文

从相册或者文件夹获取视频文件的路径!_相册选择视频路径file:///

相册选择视频路径file:///
Intent in = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);

startActivityForResult(in, REQUEST_CALENDAR);


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if(data == null ){
return;
}
if (requestCode == REQUEST_CALENDAR) {
String path=Uri.decode(data.getDataString());
Uri uri = Uri.parse(path);
path = Tool.getPathFromUri(mactivity, uri);
AppLog.d("dingdong", "path========="+path);
}else if(requestCode == REQUEST_FILE){
String path=Uri.decode(data.getDataString());
if(!MediaFile.isVideoFileType(path)){
Uri uri = Uri.parse(path);
path = Tool.getPathFromUri(mactivity, uri);
}
if(path!=null&&!"".equals(path)){
if(path.startsWith("file://")){
int position = path.indexOf("/")+2;
AppLog.d("dingdong", "position === "+position);
path = path.substring(position);
}
}

AppLog.d("dingdong", "path========="+path);
}

}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/175274
推荐阅读
相关标签
  

闽ICP备14008679号