hbisoft / pickit Goto Github PK
View Code? Open in Web Editor NEWAn Android library that returns real paths from Uri's
License: MIT License
An Android library that returns real paths from Uri's
License: MIT License
I am totally new to android 11 file access,
I have a simple question , I have an activity where we get the Song Id using MediaStore.Audio.Media._ID
, I want to pass it to an activity which uses Jaudiotagger
for which I need the file using File = new File();
which is in a separate activity.
So from activity A I pass the Intent extra like this
Long ExtraVal = SongId ; // MediaStore.Audio.Media._ID
Intent myIntent = new Intent(mcontext, ActivityToOpen);
myIntent.putExtra("ExtraVal", ExtraVal);
mcontext.startActivity(myIntent);
and in Activity B , I get it Like this,
Bundle extras = getIntent().getExtras();
if (extras == null) {
ExtraVal = null;
} else {
ExtraVal = extras.getLong("ExtraVal");
}
How can I use this Id to get the file path and pass it to File = new File()
I am a total noob so please help
Also the startActivityForResult(intent, SELECT_VIDEO_REQUEST)
is depreccated can you please update the example .
When i choose not local file , can i stop download function and just jump to PickiTonStartListener to show that online file are not supported, please choose local file
All works fine when I use pickit in onActivityResult but I get permission error when I try to use it later in my function:
String x = "content://com.android.providers.downloads.documents/document/raw%3A%2Fstorage%2Femulated%2F0%2FDownload%2FEva_Nikolskaya_Snejnaya_Zolushka.pdf";
pickiT.getPath(Uri.parse(URLDecoder.decode(x, "utf-8")), Build.VERSION.SDK_INT);
Permission denial: opening provider com.android.providers.downloads.downloadstorageprovider from processrecord requires that you obtain access using action_open_document or related apis.
I get it in PickiTonCompleteListener (String reason).
I am using this library to upload files inside my app. It returns path for all other folder but when i pick file from Document Folder it says some error occur check log files.
This library needs a license so we can use it in our apps. Have a look at here to choose the appropriate one (I recommend MIT). Then add a LICENSE
file in the root of this repo.
According to this page:
When you make a creative work (which includes code), the work is under exclusive copyright by default. Unless you include a license that specifies otherwise, nobody else can copy, distribute, or modify your work without being at risk of take-downs, shake-downs, or litigation.
In other words, nobody can legally use this library except @HBiSoft who made it.
This gem of a library is amazing in that it does what it advertises to do, but with scoped storgaes from Android 10 even with WRITE_EXTERNAL_STORAGE or the read permission File(filepath) won't be readable anymore, any good advices @HBiSoft?
I get Unsupported Uri for : content://com.android.providers.downloads.documents/tree/msd%3A11526
when I choose a directory
API 29
And I launch directory picker like this (in order to reproduce)
val intent = Intent(ACTION_OPEN_DOCUMENT_TREE).apply {
putExtra(Intent.EXTRA_LOCAL_ONLY, true)
putExtra(EXTRA_SHOW_ADVANCED, true)
}
fragment.startActivityForResult(intent, requestId)
Hi,
In your demo app, there is no option to select any file from the downloads folder. Can you help me with this?
your codes uses getExternalStorageDirectory() which will return an exception when we try to run it on Android 10 devices with targetSdkVersion 29.
file with the deprecated code https://github.com/HBiSoft/PickiT/blob/master/pickit/src/main/java/com/hbisoft/pickit/Utils.java
referring to https://developer.android.com/reference/android/os/Environment#getExternalStorageDirectory()
To improve user privacy, direct access to shared/external storage devices is deprecated. When an app targets Build.VERSION_CODES.Q, the path returned from this method is no longer directly accessible to apps. Apps can continue to access content stored on shared/external storage by migrating to alternatives such as Context#getExternalFilesDir(String), MediaStore, or Intent#ACTION_OPEN_DOCUMENT.
While using library on android less than 10 its working fine but as you go above 11 it returns path but also show error EAccess Denied while picking pdf
PickiT version
2.0.5
Hello, this is very great work.
I just have a problem/feature request, how could we get multiple file's real paths at once? As your using callbacks, you cannot call the pickit.getPath() method in loop, right?
So have you considered this scenario for your future releases? Or if you know any workaround for the same?
Thanks.
I got such crashes:
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getColumnIndex(java.lang.String)' on a null object reference
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java)
at android.os.AsyncTask$2.call + 295(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run + 237(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run + 234(AsyncTask.java:234)
at java.util.concurrent.ThreadPoolExecutor.runWorker + 1113(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run + 588(ThreadPoolExecutor.java:588)
at java.lang.Thread.run + 818(Thread.java:818)
And
Caused by java.lang.ArithmeticException: divide by zero
at com.hbisoft.pickit.DownloadAsyncTask.a + 196(DownloadAsyncTask.java:196)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground + 2(DownloadAsyncTask.java:2)
at android.os.AsyncTask$2.call + 333(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run + 266(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run + 245(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker + 1167(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run + 641(ThreadPoolExecutor.java:641)
at java.lang.Thread.run + 764(Thread.java:764)
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1120, result=-1, data=Intent { dat=content://com.android.providers.media.documents/document/image:8585 flg=0x1 }}
is there any idea why the path is null????
i am using android 11
Hi, massive thanks for this library, I have an issue, when I select a video file from (Google Photos App), I get the following exception :
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:399)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalArgumentException: Invalid column latitude
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:944)
at android.content.ContentResolver.query(ContentResolver.java:880)
at android.content.ContentResolver.query(ContentResolver.java:836)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:57)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
at android.os.AsyncTask$3.call(AsyncTask.java:378)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
The issue happens only on Android 10.0 (API 29) | Emulator, and works perfectly on other versions
Full scenario :
Start choosing a video file by clicking on the pick button > From the menu, choosing the Google Photos App> App crash immediately
Is your feature request related to a problem? Please describe.
Related to #44, you answered me that a method called pickiT.isUnknownProvider
is exposed. Meanwhile, you didn't merge or push this change at master or any other place that I saw.
Describe the solution you'd like
Probably you push it somewhere else? Please could you specify where to find this method?
This issue is just a reminder of #44 because it seem you didn't receive my comments.
Thanks in advance!
Your lib has some problems with getting the name of file from google drive. It always named as "tempFile" with no extension. Also when picking files from YandexDisk drive (https://play.google.com/store/apps/details?id=ru.yandex.disk&hl=en) it returnes wasSuccessfull false and reason "column '_data' does not exist". Also I would prefer to store files in external cache directory.
I didn't change the lib, but here is some code how I fixed both problems on my device:
@Override
public void PickiTonCompleteListener(String path, boolean wasDriveFile, boolean wasUnknownProvider, boolean wasSuccessful, String Reason) {
if (!wasSuccessful) {
String name = getFileName(originalFileUri);
File file = new File(getExternalCacheDir(), name);
try {
saveFile(getContentResolver().openInputStream(originalFileUri), file);
} catch (FileNotFoundException e) {
return;
}
path = file.getPath();
}
else if (wasDriveFile) {
String name = getFileName(originalFileUri);
File newFile = new File(getExternalCacheDir(), name);
File oldFile = new File(path);
oldFile.renameTo(newFile);
path = newFile.getPath();
}
processFile(path);
}
// https://stackoverflow.com/questions/5568874/how-to-extract-the-file-name-from-uri-returned-from-intent-action-get-content
private String getFileName(Uri uri) {
String result = null;
if (uri.getScheme().equals("content")) {
Cursor cursor = getContentResolver().query(uri, null, null, null, null);
try {
if (cursor != null && cursor.moveToFirst()) {
result = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME));
}
} finally {
cursor.close();
}
}
if (result == null) {
result = uri.getPath();
int cut = result.lastIndexOf('/');
if (cut != -1) {
result = result.substring(cut + 1);
}
}
return result;
}
private void saveFile(InputStream input, File file) {
// todo: just saves the file
}
Describe the bug
Describe the bug
A clear and concise description of what the bug is.
Log
Please provide a well-formatted bug report (by adding 4 spaces before the log)
Can it be reproduced in demo app
Yes or no
PickiT version
for example 1.0.1
Device information
Screenshots
If applicable, add screenshots to help explain your problem.
Thank you for your work here. When selecting an image from Gallery everything works.
When selecting on a "recent image" the path returned in PickiTonCompleteListener
is null.
Full Log
path: null, wasDriveFile: false, wasUnknownProvider: false, wasSuccessful: false, reason: null
In onActivityResult
this is what I'm getting when selecting a "recent image":
uri.path.toString()
: /document/image:31
uri
: content://com.android.providers.media.documents/document/image%3A31
Build.Version is 30
Is this expected behavior?
Stacktrace from Crashlytics:
Caused by java.lang.NullPointerException: Attempt to invoke interface method 'int android.database.Cursor.getColumnIndex(java.lang.String)' on a null object reference
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:68)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
at android.os.AsyncTask$2.call(AsyncTask.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Great little library,
Do you consider to put this under os license?
Hi.
Any .doc file I try to upload from drive I getting error.
If file is image or pdf is ok.
Try several files.
Can someone confirm please.
`2020-04-07 19:56:58.133 7276-7788/? E/DatabaseUtils: Writing exception to parcel
java.lang.SecurityException: Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc%3D1%3Bdoc%3Dencoded%3D%2F2UAjJF6sM03B39hXL5nCqpt0ccgmnJO%2BWip%2FsaCpZPuDWXQVA%3D%3D from pid=6564, uid=10231 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.content.ContentProvider.enforceReadPermissionInner(ContentProvider.java:634)
at android.content.ContentProvider$Transport.enforceReadPermission(ContentProvider.java:503)
at android.content.ContentProvider$Transport.query(ContentProvider.java:214)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:102)
at android.os.Binder.execTransact(Binder.java:735)
--------- beginning of crash
2020-04-07 19:56:58.166 6564-7789/com.papinho E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #7
Process: com.papinho, PID: 6564
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.SecurityException: Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc%3D1%3Bdoc%3Dencoded%3D%2F2UAjJF6sM03B39hXL5nCqpt0ccgmnJO%2BWip%2FsaCpZPuDWXQVA%3D%3D from pid=6564, uid=10231 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.os.Parcel.createException(Parcel.java:1950)
at android.os.Parcel.readException(Parcel.java:1918)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
at android.content.ContentResolver.query(ContentResolver.java:802)
at android.content.ContentResolver.query(ContentResolver.java:752)
at android.content.ContentResolver.query(ContentResolver.java:710)
at com.hbisoft.pickit.DownloadAsyncTask.getFileName(DownloadAsyncTask.java:119)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:79)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:18)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
`
Whenever I select any file from downloads with filename containing spaces, it is giving me an error file not found exception & also a toast in a different language. Please provide a fix for this.
I have the traced the issue - it is due to invalid characters in the filename and we need to replace them with an underscore.
Android -10
Hi,
By adding the PickiT library (implementation com.github.HBiSoft:PickiT:0.1.6
) on my project the build.gradle fails when it is trying to sync.
Do you have any idea why this is happening? Do you have any similar incident until now? Maybe it's a conflict with other existing implementations on my build.gradle?
Please let me know how can I help you to send more information to investigate the issue in further.
Note: Awesome job from your side to create such a library for the community. Because it's a mess on Android how to handle the real path for a content Uri.
Not an issue or bug, but just a question regarding the new Google Play policy,
We've detected that your app contains the requestLegacyExternalStorage flag in the manifest file of 1 or more of your app bundles or APKs.
Developers with apps on devices running Android 11+ must use Scoped Storage to give users better access control over their device storage. To release your app on Android 11 or newer after May 5th, you must either:
Update your app to use more privacy friendly best practices, such as the Storage Access Framework or Media Store API Update your app to declare the All files access (MANAGE_EXTERNAL_STORAGE) permission in the manifest file, and complete the All files access permission declaration in Play Console from May 5th Remove the All files access permission from your app entirely For apps targeting Android 11, the requestLegacyExternalStorage flag will be ignored. You must use the All files access permission to retain broad access.
SOURCE : https://support.google.com/googleplay/android-developer/answer/10467955?hl=en&ref_topic=2364761
My app :
targetSDK = 30
requestLegacyExternalStorage = true
Permissions :
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Good JOB dear, impressive +1)
Thanks for putting so many efforts, are we handling in Android 10 file not found exception? Something I tried is -
<manifest ... >
<application android:requestLegacyExternalStorage="true" ... >
...
</application>
</manifest>
Caused by java.lang.SecurityException
Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc%3D3%3Bdoc%3Dencoded%3Do64-UNpfLjl3z8K-7vho6s1Mbnr0UzMJ7rMp3BBn0-ummr0WCPWDUMQG40jDScPuID78 from pid=26080, uid=10380 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
Caused by java.lang.SecurityException: Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc%3D3%3Bdoc%3Dencoded%3Do64-UNpfLjl3z8K-7vho6s1Mbnr0UzMJ7rMp3BBn0-ummr0WCPWDUMQG40jDScPuID78 from pid=26080, uid=10380 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.os.Parcel.createExceptionOrNull(Parcel.java:2389)
at android.os.Parcel.createException(Parcel.java:2373)
at android.os.Parcel.readException(Parcel.java:2356)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderProxy.java:473)
at android.content.ContentResolver.query(ContentResolver.java:1192)
at android.content.ContentResolver.query(ContentResolver.java:1124)
at android.content.ContentResolver.query(ContentResolver.java:1080)
at com.hbisoft.pickit.DownloadAsyncTask.getFileName(DownloadAsyncTask.java:135)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:96)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
please do update for jcenter migration please
I'm using ACTION_OPEN_DOCUMENT but still getting this crash.
implementation 'com.github.HBiSoft:PickiT:2.0.5'
context?.let { context ->
pdfPicker = PickiT(context, this, activity)
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT).apply {
addCategory(Intent.CATEGORY_OPENABLE)
type = "application/pdf"
}
launchForPDF.launch(Intent.createChooser(intent, "ChooseFile"))
}
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:353)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.docs.storagebackend.StorageBackendContentProvider from ProcessRecord{20aefd9 3737:com.hmblapps.scanner/u0a260} (pid=3737, uid=10260) requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.os.Parcel.readException(Parcel.java:2013)
at android.os.Parcel.readException(Parcel.java:1959)
at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:4793)
at android.app.ActivityThread.acquireProvider(ActivityThread.java:5899)
at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2557)
at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:1780)
at android.content.ContentResolver.query(ContentResolver.java:738)
at android.content.ContentResolver.query(ContentResolver.java:704)
at android.content.ContentResolver.query(ContentResolver.java:662)
at com.hbisoft.pickit.DownloadAsyncTask.getFileName(DownloadAsyncTask.java:28)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:209)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
Could not open file stream which is selected from downloads on OnePlus Nord OS version 12,
PickiTonCompleteListener returns wasSuccessful=true & also returns file path.
android:requestLegacyExternalStorage="true" is also set in manifest file
Log:
PickiTonCompleteListener: selectedFilePath: /storage/emulated/0/Download/PaymentReceipt_21748557_.pdf , wasDriveFile: false, wasUnknownProvider: false
W/System.err: java.io.FileNotFoundException: /storage/emulated/0/Download/PaymentReceipt_21748557_.pdf: open failed: EACCES (Permission denied)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:574)
W/System.err: at java.io.FileInputStream.(FileInputStream.java:160)
W/System.err: at com.checkup.app.authenticationAndProfile.AddChildProfileActivity.convertImageFileToBase64(AddChildProfileActivity.kt:641)
W/System.err: at com.checkup.app.authenticationAndProfile.AddChildProfileActivity$PickiTonCompleteListener$1.invoke(AddChildProfileActivity.kt:1103)
W/System.err: at com.checkup.app.authenticationAndProfile.AddChildProfileActivity$PickiTonCompleteListener$1.invoke(AddChildProfileActivity.kt:1102)
W/System.err: at org.jetbrains.anko.AsyncKt$doAsync$1.invoke(Async.kt:143)
W/System.err: at org.jetbrains.anko.AsyncKt$doAsync$1.invoke(Unknown Source:0)
W/System.err: at org.jetbrains.anko.AsyncKt$sam$java_util_concurrent_Callable$0.call(Unknown Source:2)
W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:264)
W/System.err: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:307)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
W/System.err: at java.lang.Thread.run(Thread.java:1012)
W/System.err: Caused by: android.system.ErrnoException: open failed: EACCES (Permission denied)
W/System.err: at libcore.io.Linux.open(Native Method)
W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
W/System.err: at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
W/System.err: at libcore.io.ForwardingOs.open(ForwardingOs.java:563)
W/System.err: at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8094)
W/System.err: at libcore.io.IoBridge.open(IoBridge.java:560)
it be reproduced in demo app
PickiT version: 2.0.5
Device information
OnePlus Nord AC2001
SDK version: 31 (Android 12)
It looks like the library doesn't support the use case when the user selects a Google Photo that isn't on their phone (ie. backed up from archives).
This is the content uri: content://com.google.android.apps.photos.contentprovider/4/1/mediakey%3A%2Flocal%253Ae4e33dc7-fbde-4497-b771-d8099e6b1793/ORIGINAL/NONE/903022857
and Utils.getRealPathFromURI_API19(this, selectedImageUri)
returns null
Picking from Google photos with an image that exists on the devices works as expected.
Any thoughts here?
Describe the bug
Actually, if I try to pass an absolute path to getPath
, the program throw an exception.
The correct behavior should be to return the same path you put in if already is an absolute path? This could happen when receiving a sharing intent and android copy the file into application cache files.
From the existing absolute I do de following before ask getPath
:
val uri: Uri = Uri.parse(absoluteUriPath!!)
val clip = ClipData.newUri(
activity.getContentResolver(), "AbsolutePath",
uriPath
)
pickiT?.getPath(clipData.getItemAt(0).getUri(), Build.VERSION.SDK_INT)
Log
Here the stack trace of the error:
E/MethodChannel#flutter_file_dialog(20683): java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter path
E/MethodChannel#flutter_file_dialog(20683): at com.kineapps.flutter_file_dialog.FileDialog.PickiTonCompleteListener(Unknown Source:2)
E/MethodChannel#flutter_file_dialog(20683): at com.hbisoft.pickit.PickiT.getPath(PickiT.java:162)
E/MethodChannel#flutter_file_dialog(20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePath(FileDialog.kt:228)
E/MethodChannel#flutter_file_dialog(20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePath(FileDialog.kt:242)
E/MethodChannel#flutter_file_dialog(20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePathFromUri(FileDialog.kt:156)
E/MethodChannel#flutter_file_dialog(20683): at com.kineapps.flutter_file_dialog.FlutterFileDialogPlugin.onMethodCall(FlutterFileDialogPlugin.kt:138)
E/MethodChannel#flutter_file_dialog(20683): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:259)
E/MethodChannel#flutter_file_dialog(20683): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/MethodChannel#flutter_file_dialog(20683): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
E/MethodChannel#flutter_file_dialog(20683): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/MethodChannel#flutter_file_dialog(20683): at android.os.Handler.handleCallback(Handler.java:938)
E/MethodChannel#flutter_file_dialog(20683): at android.os.Handler.dispatchMessage(Handler.java:99)
E/MethodChannel#flutter_file_dialog(20683): at android.os.Looper.loop(Looper.java:223)
E/MethodChannel#flutter_file_dialog(20683): at android.app.ActivityThread.main(ActivityThread.java:7664)
E/MethodChannel#flutter_file_dialog(20683): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter_file_dialog(20683): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#flutter_file_dialog(20683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (20683): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(error, Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter path, null, java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter path
E/flutter (20683): at com.kineapps.flutter_file_dialog.FileDialog.PickiTonCompleteListener(Unknown Source:2)
E/flutter (20683): at com.hbisoft.pickit.PickiT.getPath(PickiT.java:162)
E/flutter (20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePath(FileDialog.kt:228)
E/flutter (20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePath(FileDialog.kt:242)
E/flutter (20683): at com.kineapps.flutter_file_dialog.FileDialog.getAbsolutePathFromUri(FileDialog.kt:156)
E/flutter (20683): at com.kineapps.flutter_file_dialog.FlutterFileDialogPlugin.onMethodCall(FlutterFileDialogPlugin.kt:138)
E/flutter (20683): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:259)
E/flutter (20683): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:296)
E/flutter (20683): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:320)
E/flutter (20683): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$TsixYUB5E6FpKhMtCSQVHKE89gQ.run(Unknown Source:12)
E/flutter (20683): at android.os.Handler.handleCallback(Handler.java:938)
E/flutter (20683): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter (20683): at android.os.Looper.loop(Looper.java:223)
E/flutter (20683): at android.app.ActivityThread.main(ActivityThread.java:7664)
E/flutter (20683): at java.lang.reflect.Method.invoke(Native Method)
E/flutter (20683): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/flutter (20683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter (20683): )
E/flutter (20683): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (20683): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:167:18)
E/flutter (20683): <asynchronous suspension>
E/flutter (20683): #2 _MyAppState._absoluteFromAbsolute (package:flutter_file_dialog_example/main.dart:185:14)
E/flutter (20683): <asynchronous suspension>
E/flutter (20683):
Can it be reproduced in demo app
No.
PickiT version
'com.github.HBiSoft:PickiT:2.0.5'
Device information
So, I choose a PDF file, the file is inside a folder (/PRINT/PRINT/front.pdf) on "Download" folder
I get "/storage/emulated/0/Download/front.pdf"
Instead of "/storage/emulated/0/Download/PRINT/PRINT/front.pdf"
How can I solve the problem?
Device: Samsung Note 9
Version: Android 10
Above android 9
I am using the library to get the path from the URI of videos after selecting them from the download folder using ACTION_PICK like the example code. after generating the path using the library and passing it to FFmpeg Kit the app gives me that error
2022-01-22 06:19:30.751 13954-13998/com.hbisoft.pickitexample E/ffmpeg-kit: [concat @ 0xc5da8000] Impossible to open '/storage/emulated/0/Download/first_video.mp4' 2022-01-22 06:19:30.751 13954-13998/com.hbisoft.pickitexample E/ffmpeg-kit: /data/user/0/com.hbisoft.pickitexample/cache/ffmpeg-list1945350936764214333.txt: Permission denied
@Override
public void PickiTonMultipleCompleteListener(ArrayList<String> paths, boolean wasSuccessful, String Reason) {
if (mdialog != null && mdialog.isShowing()) {
mdialog.cancel();
}
StringBuilder allPaths = new StringBuilder();
for (int i = 0; i < paths.size(); i++) {
allPaths.append("\n").append(paths.get(i)).append("\n");
}
// Set returned path to TextView
pickitTv.setText(allPaths.toString());
// Make TextView's visible
originalTitle.setVisibility(View.VISIBLE);
originalTv.setVisibility(View.VISIBLE);
pickitTitle.setVisibility(View.VISIBLE);
pickitTv.setVisibility(View.VISIBLE);
mVideosList = generateList(paths.toArray(new String[0]));
}
private static String generateList(String[] inputs) {
File list;
Writer writer = null;
try {
list = File.createTempFile("ffmpeg-list", ".txt");
writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(list)));
for (String input : inputs) {
writer.write("file '" + input + "'\n");
Log.d(TAG, "Writing to list file: file '" + input + "'");
}
} catch (IOException e) {
e.printStackTrace();
return "/";
} finally {
try {
if (writer != null)
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
Log.d(TAG, "Wrote list file to " + list.getAbsolutePath());
return list.getAbsolutePath();
}
findViewById(R.id.start_combine_button).setOnClickListener(view -> {
FFmpegKit.executeAsync("-f concat -safe 0 -i " + mVideosList + " -c copy " + mOutputDirectory.getPath(),
new FFmpegSessionCompleteCallback() {
@Override
public void apply(FFmpegSession session) {
Log.d(TAG, "getCommand: " + session.getCommand());
Log.d(TAG, "getFailStackTrace: " + session.getFailStackTrace());
}
});
});
Describe the bug
getPath is unable to get the path of an image in the downloads folder for android 9 (API 28) specifically. Testing on API 27 works as expected. I assume that the path utility is missing certain cases for this type of provider.
Log
The file used to test is a simple .jpeg
file of a medium size. Using a URI that originates from the File Manager (i.e. not the gallery).
Example URI: content://com.android.providers.downloads.documents/document/9
The response in the PickiTonCompleteListener
:
Can it be reproduced in demo app
No this is for the following reason:
content://com.android.providers.media.documents
URI. Notice that this is a media URI and not a downloads URI. If a downloads/documents URI is obtained through other means (like for example sharing an image with an app), then this URI does not work. The demo app can't get URIs of the type stated above for Android 9.PickiT version
Device information
Hi,
First, thank you for your awesome library, it really helps me 🙂
I noticed an issue when trying to get a google doc / google sheet file from Google Drive. Drive gives the file as a PDF, however, the DownloadAsyncTask crash because size is somehow equal to zero
E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #2
Process: com.smashco.smash, PID: 3924
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:354)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ArithmeticException: divide by zero
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:98)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
at android.os.AsyncTask$2.call(AsyncTask.java:333)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by java.lang.SecurityException
Permission Denial: opening provider com.google.android.libraries.storage.storagelib.FileProvider from ProcessRecord{4362fa7d0 18613:package.name/u0a1183} (pid=18613, uid=11183) that is not exported from UID 10198
This bug occused when open file from file manager.
I think it happen with devices have removable-storage (sdcard)
Describe the bug
After upgrading to PickIt 2.0.3
we implemented the method pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)
. For some images, the program crash unexpectedly.
Describe the bug
We have this line where it crash:
if(pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT) || !pickiT.wasLocalFileSelected(uri)) {
result.error("IS_REMOTE_FILE", "The selected file is remote and is not implemented yet", null);
}
And for this file content://com.android.providers.media.documents/document/image%3A66
the program crash.
But NOT for this content://com.android.providers.media.documents/document/image%3A65
Both are local (I can see them without internet connection). And if I disable the pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)
it still crashing. Neither downgrading to previous pickit version.
We also upgraded sdk from 30 to 31.
Log
E/AndroidRuntime(29424): FATAL EXCEPTION: AsyncTask #1
E/AndroidRuntime(29424): Process: net.altermundi.elrepoio, PID: 29424
E/AndroidRuntime(29424): java.lang.RuntimeException: An error occurred while executing doInBackground()
E/AndroidRuntime(29424): at android.os.AsyncTask$4.done(AsyncTask.java:399)
E/AndroidRuntime(29424): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
E/AndroidRuntime(29424): at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
E/AndroidRuntime(29424): at java.util.concurrent.FutureTask.run(FutureTask.java:271)
E/AndroidRuntime(29424): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
E/AndroidRuntime(29424): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/AndroidRuntime(29424): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/AndroidRuntime(29424): at java.lang.Thread.run(Thread.java:919)
E/AndroidRuntime(29424): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.runOnUiThread(java.lang.Runnable)' on a null object reference
E/AndroidRuntime(29424): at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:71)
E/AndroidRuntime(29424): at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:19)
E/AndroidRuntime(29424): at android.os.AsyncTask$3.call(AsyncTask.java:378)
E/AndroidRuntime(29424): at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/AndroidRuntime(29424): ... 4 more
I/Process (29424): Sending signal. PID: 29424 SIG: 9
PickiT version
2.0.3
Device information
Redmi 9A MIUI 12.0.9
compileSdkVersion 31
minSdkVersion 16
Is your feature request related to a problem? Please describe.
You can use wasLocalFileSelected
to check if is a local file before trying to get it locally, for example, to notice the user the file is going to be downloaded before access it.
Unfortunately, you have to use getPath
before know if is an unknown provider, causing, if I understood it well, the tmp copy download into project directory, without a way to check this before
Describe the solution you'd like
A function such as isUnknownProvider
could be useful to use it before getPath
and download the temporary file.
Hi,
I started to develop a Flutter plugin that implements this library:
https://gitlab.com/elRepo.io/flutter_absolute_path
I'm still developing it, remote files are not supported yet, and I'm going to make some changes, but now local file path is working well.
That's it!
implementation 'com.github.HBiSoft:PickiT:2.0.3'
Fatal Exception: java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$4.done(AsyncTask.java:415)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Caused by java.lang.SecurityException: Permission Denial: reading com.google.android.apps.docs.storagebackend.StorageBackendContentProvider uri content://com.google.android.apps.docs.storage/document/acc%3D2%3Bdoc%3Dencoded%3D0ap1EmWcFP7yBkFDVTwpCmtcuoPnD-uU5gpAc4SJwf86WBFPVc_gwMyIbZjh from pid=18854, uid=10543 requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
at android.os.Parcel.createExceptionOrNull(Parcel.java:2385)
at android.os.Parcel.createException(Parcel.java:2369)
at android.os.Parcel.readException(Parcel.java:2352)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:190)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderProxy.java:472)
at android.content.ContentResolver.query(ContentResolver.java:1186)
at android.content.ContentResolver.query(ContentResolver.java:1118)
at android.content.ContentResolver.query(ContentResolver.java:1074)
at com.hbisoft.pickit.DownloadAsyncTask.getFileName(DownloadAsyncTask.java:28)
at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(DownloadAsyncTask.java:209)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Describe the bug
Log
java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider.impl.MediaContentProvider from ProcessRecord{c17cc1b 26188:com.einpix.android/u0a165} (pid=26188, uid=10165) that is not exported from UID 10143 at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) at android.os.Parcel.createException(Parcel.java:2357) at android.os.Parcel.readException(Parcel.java:2340) at android.os.Parcel.readException(Parcel.java:2282) at android.app.IActivityManager$Stub$Proxy.getContentProvider(IActivityManager.java:5736) at android.app.ActivityThread.acquireProvider(ActivityThread.java:6877) at android.app.ContextImpl$ApplicationContentResolver.acquireUnstableProvider(ContextImpl.java:2936) at android.content.ContentResolver.acquireUnstableProvider(ContentResolver.java:2481) at android.content.ContentResolver.query(ContentResolver.java:1167) at android.content.ContentResolver.query(ContentResolver.java:1115) at android.content.ContentResolver.query(ContentResolver.java:1071) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(SourceFile:62) at com.hbisoft.pickit.DownloadAsyncTask.doInBackground(SourceFile:19) at android.os.AsyncTask$3.call(AsyncTask.java:394) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:923)
Can it be reproduced in demo app
No
PickiT version
for example 0.1.14
Device information
Return wrong path
Expect
Return path: xxx/KakaotalkDownload/filename
Can it be reproduced in demo app
Yes
Device information
Screenshots
It is not possible to predict the cause of an error without a log, knowing your environment, understanding what you are trying to achieve or which steps you took.
So, please fill in the issue template when creating an issue.
Issues that do not fill out the issue template fields will be closed immediately until the fields are filled in.
Describe the bug
If you select a file that is inside a subfolder inside the downloads tab, pickit returns path of the file without the subfolder name.
Can it be reproduced in demo app
Yes
PickiT version
0.1.14
Device information
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.