permission denial
slonomag opened this issue · comments
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).
The error tells you what the issue is. You cannot use a content
uri like to are trying to. If you have a look at the demo project, I do the following:
intent.setAction(Intent.ACTION_GET_CONTENT);
In your case you will have to pass :
intent.setAction(Intent. ACTION_OPEN_DOCUMENT);
Thanks!
Hi once again!
I found an additional issue with using Uri later when you write it in database and then get it back for future usage. After saving in database you get the path with "raw%3A%2F" instead of "raw:". I downloaded your library and updated Utils.java on lines 63-65 from:
if (id.startsWith("raw:")) {
id = id.replaceFirst("raw:", "");
....
to
if (id.startsWith("raw:") || id.startsWith("raw%3A%2F")) {
id = id.replaceFirst("raw:", "");
id = id.replaceFirst("raw%3A%2F", "");
....
and all works fine now. Please update your library on github too.
Thanks!
@slonomag Thanks for this. I've made the changes and it is available in 0.1.8
.