Closed lamhuynh96 closed 7 years ago
Hey @lamhuynh96, sorry for the delay. Were you able to solve the problem?
I added permission request to the sample project and now it works on Android 6+. Looking at your code I don't see any issues but it is definitely somewhere around permissions request.
@RustamG I've tried other dialog libraries and discovered that android 6+ doesn't give access to storage files instantly after permission granted. My solution was putting some code to restart application and everything would work fine.
With your new code added, can we skip the restart step?
I don't restart the app manually. I used RxPermissions library to make the code clear. However sometimes it crashed when I tried to ask permissions just before opening the file dialog. There is important note that you need to ask permissions during activity/fragment initialization (i.e onCreate). After putting permissions dialog to activity's onCreate()
, everything worked fine. You can look the whole code here.
Anyway, good to hear that you solved the problem :)
Thanks for your help. Keep up your nice work!
I just ask for storage read and write permission for the 1st time before lauching FileDialog, after permissions are granted, app crashes with this error:
FATAL EXCEPTION: main Process: vlab.itpc, PID: 7572 java.lang.IllegalArgumentException: Files list is null. Please make sure that you have read permission to this directory. Have you added android.permission.READ_EXTERNAL_STORAGE permission to your AndroidManifest.xml? at com.rustamg.filedialogs.FileListAdapter.<init>(FileListAdapter.java:31) at com.rustamg.filedialogs.FileDialog$UpdateFilesTask.onPostExecute(FileDialog.java:251) at com.rustamg.filedialogs.FileDialog$UpdateFilesTask.onPostExecute(FileDialog.java:203) at android.os.AsyncTask.finish(AsyncTask.java:660) at android.os.AsyncTask.-wrap1(AsyncTask.java) at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:677) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6095) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
After relaunching app, everything is fine.` This is my activity code: https://ideone.com/i9ivs9. The request permission code works fine in other app. Before relaunch after app crash, I also check and see that all permissions are granted in the app settings. Can you have a look at this issue? Thank you.