我尝试使用Android Studio创建可以在SD卡中选择文件并获取其路径的应用,就像row
一样,我试过这个:
OpenFileDialog
然而,它不起作用,我该怎么办?
答案 0 :(得分:0)
试试这个:
Intent mediaIntent = new Intent(Intent.ACTION_GET_CONTENT);
mediaIntent.setType("*/*"); //set mime type as per requirement
startActivityForResult(mediaIntent,0);
您可以根据需要更改类型。
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0
&& resultCode == Activity.RESULT_OK) {
Uri uri = data.getData();
Log.d("", "Video URI= " + videoUri);
}
}