我有一个活动,可以通过ACTION_VIEW接收意图," application / octet-stream"哑剧类型。 当我收到来自" Google Drive"的文件时Android应用程序,Uri在Intent Extra的getParcelableExtra()中,一切正常。
Uri returnUri = getIntent().getParcelableExtra(Intent.EXTRA_STREAM);
if (returnUri == null)
returnUri = getIntent().getData();
ParcelFileDescriptor mInputPFD;
try {
// Get the content resolver instance for this context, and use
// it to get a ParcelFileDescriptor for the file.
mInputPFD = getContentResolver().openFileDescriptor(uri, "r"); //Line:87 (Exception here)
}
catch (FileNotFoundException e)
{
e.printStackTrace();
Log.e("MainActivity", "File not found.");
return false;
}
// Get a regular file descriptor for the file
FileDescriptor fd = mInputPFD.getFileDescriptor();
但是当我收到来自" OneDrive"的意图时Android应用程序,Uri在getData()中,当我尝试从Uri获取ParcelFileDescriptor时,我收到一个异常:
java.io.FileNotFoundException: Not a whole file
at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:542)
at <one of my classes>(<class name>.java:87)
修改 我为Google云端硬盘和OneDrive选择了相同的文件