Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
intent.setType("image/*");
intent.setType("video/*");
// intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, READ_REQUEST_CODE)
if (requestCode == READ_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
// The document selected by the user won't be returned in the intent.
// Instead, a URI to that document will be contained in the return intent
// provided to this method as a parameter.
// Pull that URI using resultData.getData().
Uri uri = null;
if (resultData != null) {
uri = resultData.getData();
uri1 = uri;
Log.i("anderwidth", "Uri: " + uri.toString());
File file = new File(uri1.getPath());
}
}
我使用改裝與Android閱讀。那是什麼發生?我無法讀取圖像和視頻作爲文件,file.exists給我false.Everytime其內容// ...
它的工作原理,如果有人下載的文件管理器應用程序,而不是如果沒有下載。
'File file = new File(uri1.getPath());'。這是行不通的。請發佈uri1.getPath()和uri2.toString()的完整值。 – greenapps