Code Monkey home page Code Monkey logo

pickit's Introduction

Creating and maintaining a library like this takes a lot of time.
If you would like to thank me, you can do so below:

Buy Me A Coffee



PickiT

Android Arsenal

An Android library that returns real paths from Uri's


Demo screenshot:

Download the demo app here



Add Pickit to your project:

Add the following in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Then, add the dependency, in your app level build.gradle:

dependencies {
    implementation 'com.github.HBiSoft:PickiT:2.0.5'
}

Implementation:

First, implement PickiT callbacks, as shown below:

public class MainActivity extends Activity implements PickiTCallbacks {

Alt+Enter to implement the methods, we will discuss the methods later in the readme.

Implement pickiT in your onCreate() method, as shown below:

public class MainActivity extends AppCompatActivity implements PickiTCallbacks {
    //Declare PickiT
    PickiT pickiT;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Initialize PickiT
        //context, listener, activity
        pickiT = new PickiT(this, this, this);

    }
}

You can now select a file as you usually would (have a look at the demo if you don't know how to do this).

Then in onActivityResult, you can pass the path to PickiT, as shown below:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == SELECT_VIDEO_REQUEST) {
        if (resultCode == RESULT_OK) {
            pickiT.getPath(data.getData(), Build.VERSION.SDK_INT);

        }
    }
}

Dropbox, Google Drive, OneDrive and files from unknown file providers:

You can check if the Uri is from Dropbox,Google Drive or OneDrive by calling:

if (!pickiT.wasLocalFileSelected(uri)){
    // Drive file was selected
}

You can check if the Uri is from an unknown provider by calling:

if (pickiT.isUnknownProvider(uri, Build.VERSION.SDK_INT)){
    // Uri is from unknown provider
}

If the selected file was from Dropbox,Google Drive, OneDrive or an unknown file provider, it will then be copied/created in
Internal Storage - Android - data - your.package.name - files - Temp

It is your responsibility to delete the file when you are done with it, by calling:

pickiT.deleteTemporaryFile(Context);

This can be done in onBackPressed and onDestroy, as shown below:

@Override
public void onBackPressed() {
    pickiT.deleteTemporaryFile(this);
    super.onBackPressed();
}

@Override
public void onDestroy() {
    super.onDestroy();
    if (!isChangingConfigurations()) {
        pickiT.deleteTemporaryFile(this);
    }
}

If you do not call pickiT.deleteTemporaryFile(Context);, the file will remain in the above mentioned folder and will be overwritten each time you select a new file from Dropbox,Google Drive, OneDrive or an unknown file provider.

Manifest

If you are targeting SDK 29> add android:requestLegacyExternalStorage="true" in your manifest:

<manifest ... >
  <application 
    android:requestLegacyExternalStorage="true" 
  </application>
</manifest>

The reason for this is, in Android 10 file path access was removed and it returned in Android 11.
If you are targiting SDK 29> and you do not add this, you will get EACCES (Permission denied)

Callback methods

//When selecting a file from Google Drive, for example, the Uri will be returned before the file is available(if it has not yet been cached/downloaded).
//We are unable to see the progress
//Apps like Dropbox will display a dialog inside the picker
//This will only be called when selecting a drive file
@Override
public void PickiTonUriReturned() {
    //Use to let user know that we are waiting for the application to return the file
    //See the demo project to see how I used this.
}

//Called when the file creations starts (similar to onPreExecute)
//This will only be called if the selected file is not local or if the file is from an unknown file provider
@Override
public void PickiTonStartListener() {
    //Can be used to display a ProgressDialog
}

//Returns the progress of the file being created (in percentage)
//This will only be called if the selected file is not local or if the file is from an unknown file provider
@Override
public void PickiTonProgressUpdate(int progress) {
    //Can be used to update the progress of your dialog
}

//If the selected file was a local file then this will be called directly, returning the path as a String.
//String path - returned path
//boolean wasDriveFile - check if it was a drive file
//boolean wasUnknownProvider - check if it was from an unknown file provider
//boolean wasSuccessful - check if it was successful
//String reason - the get the reason why wasSuccessful returned false
@Override
public void PickiTonCompleteListener(String path, boolean wasDriveFile, boolean wasUnknownProvider, boolean wasSuccessful, String reason) {
    //Dismiss dialog and return the path
}

Have a look at the demo project if you have any issues implementing the library.

pickit's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pickit's Issues

Crash on HTC Desire Android 5.1

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)

Error Acessing docs from Google Drive

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) 
`

Error when picking from Google Photos that requires a download

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?

permission denial

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).

device-2019-12-08-201604

open failed: ENOENT (No such file or directory) Android 10

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

Android 10 open failed: EACCES (Permission denied)

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>

Help with multiple files

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.

crash on recent image file

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

Always fill in the issue template

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.

Error if getPath parameter already is an absolute path

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:

Expand log
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

  • Miui Android 10
  • LineageOs Android 11

Android 12 > open failed: EACCES (Permission denied)

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)

Crash:DownloadAsyncTask.java:84

Hi, massive thanks for this library, I have an issue in DownloadAsyncTask class

Caused by java.lang.IllegalStateException
Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
com.hbisoft.pickit.DownloadAsyncTask.doInBackground

Screenshot from 2020-12-09 11-10-27

Caused by java.lang.SecurityException: Permission Denial

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)

Return wrong path

Return wrong path

  • After choosing a file from Intent in KakaotalkDownload, but data from pickiT.getPath in Download folder
  • So, I received FileNotFoundException.

Expect
Return path: xxx/KakaotalkDownload/filename

Can it be reproduced in demo app
Yes

Device information

  • Samsung Note 10 Lite
  • SDK version: 29 (Android 10)

Screenshots

Screenshot_20210227-163755_PickiT example
Screenshot_20210227-163730_My Files

Downloads

Hi,

In your demo app, there is no option to select any file from the downloads folder. Can you help me with this?

An isUnknownProvider function could be util

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.

Add license

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.

how can we pass Media store Id to get the file

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 .

Android API 28: getPath of a Downloads URI not working

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:
image

Can it be reproduced in demo app
No this is for the following reason:

  • The demo app uses a picker intent to get the URI, this returns a 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

  • 0.1.14

Device information

  • Pixel 2 (Emulator)
  • API 28

Problems with naming files from google drive. Not supported yandex disk.

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
    }

DownloadAsyncTask divide by zero

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) 

Unsupported Uri when user choose a directory

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)

Android- Crash on Android 9

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)

java.lang.SecurityException: Permission Denial: opening provider com.google.android.apps.photos.contentprovider

Describe the bug

  • I am getting crash log from live App.

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

  • WP5 Pro/RP1A.200720.011
  • Android 11

Crash SecurityException Permission Denial

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)

  • Device: Galaxy S8
  • Android: 9
    Please check it, thank you <3

Android 10 devices getting EACCES (Permission denied)

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.

isUnknownProvider doesn't exist

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!

Path for Document Folder

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.

Scoped Storage warning messages

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"/>

File not found exception when picking file from downloads

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

mpossible to open '/storage/emulated/0/Download/first_video.mp4'

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());

                        }

                    });

        });

Check if the selected file is a local file

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

Android 11 we can't fetch pdf file and store own path. Can you please check?

Describe the bug

  • Please fill in all the information below.
  • Have a look at previously asked questions to see if your issue has been resolved.
  • Properly format your issue.
  • All issues should be asked in English.
  • Delete all the above before posting your issue

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

  • Make/model
  • SDK version

Screenshots
If applicable, add screenshots to help explain your problem.

Selecting a recent image in gallery doesn't seem to work

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?

Crashes

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)

Crash for some images

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

  • Make/model

Redmi 9A MIUI 12.0.9

  • SDK version
 compileSdkVersion 31
minSdkVersion 16

Android Studio 3.3 - Adding PickiT library build.gradle fails

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.

EAccess Denied to path on Android 11

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

SecurityException

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)

Working with scoped storage

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?

Caused by: java.lang.IllegalArgumentException: Invalid column latitude

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.