-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android API 29 uses msf: prefix for downloaded files uri id? #2
Comments
And I forgot to say a big thanks to your excellent article. |
Hello @tamo , As for the issue, I managed to reproduce it by downloading a video file via the Chrome app on Android 10 emulator. Unfortunately, just skipping the 'msf:' part doesn't help to make a proper Uri that could lead us to a file path. That is why I decided to just fallback to the File Descriptor in this case. The code change is already merged. Thanks for pointing this thing out. |
Thanks for the fix. For now your fix seems the only way to go. Googling MSF tells me only about medical information. And I'm looking forward to see the new release. |
I tried this solution and its worked.
P.S. You may need to clear the cache directory after finished |
@AliElDerawi , you are trying to solve just a slightly different problem here. The original issue was about having the prefix in the URI. After that I acutually found a way of accessing files by a FileDescriptor (even if it isn't perfect). Regarding copying the file to the cache, I wouldn't do such a thing. Original files can be very big (like movies) and actually I don't want to copy user's data, because it would lead to my Privacy Policy changing. |
Hello guys, Thus, here is the solution to get a path, without copying it.
Try to implement this.
|
@SanskarDahiya String id = DocumentsContract.getDocumentId(uri);
if (id.startsWith("msf")){
final String[] split = id.split(":");
final String selection = "_id=?";
final String[] selectionArgs = new String[] { split[1] };
Log.e("Returned ", getDataColumn(context, MediaStore.Downloads.EXTERNAL_CONTENT_URI, selection, selectionArgs));
} The Here is my private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};
try {
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
final int index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(index);
}
}catch (Exception e) {
e.printStackTrace();
} finally {
if (cursor != null)
cursor.close();
}
return null;
} The Is there something I'm doing wrong? |
Hi @HBiSoft Sill I'm facing an issue to get paths from some URI's in specific devices. I don't know what to do now. |
On an emulated Pixel2 API 29, WhatTheCodec fails to open mp4s in Downloads.
Seems like the uri looks like "content://com.android.providers.downloads.documents/document/msf:24"
and the "msf:" is not needed.
So PathUtil.java needs something like:
The logcat follows:
The text was updated successfully, but these errors were encountered: