0

I have a phote-editing app registered on ACTION_SEND for images. This works perfectly.

This is how I access the file from the intent:

Uri intentUri = null;
if (Build.VERSION.SDK_INT >= 16) {
  ClipData clipData = intent.getClipData();
  if (clipData != null) {
    intentUri = clipData.getItemAt(0).getUri();
  }
}
if (intentUri == null) {
  intentUri = (Uri) intent.getExtras().get(Intent.EXTRA_STREAM);
}
FileUtil.copyFile(getContentResolver().openInputStream(intentUri), new File(documentPath));

Recently, sharing from the facebook app is failing on:

 java.io.FileNotFoundException: /data/user/0/com.facebook.katana/cache/fb_temp/.facebook_1475750693248.jpg: open failed: EACCES (Permission denied)
at libcore.io.IoBridge.open(IoBridge.java:456)
at java.io.FileInputStream.<init>(FileInputStream.java:76)
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at android.content.ContentResolver.openInputStream(ContentResolver.java:644)

What am I doing wrong?

Gili Garibi
  • 416
  • 2
  • 13
  • Hi have you set the permissions in the android manifest? And have a look at the following links:[http://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android](http://stackoverflow.com/questions/8854359/exception-open-failed-eacces-permission-denied-on-android) and [http://stackoverflow.com/questions/33030933/android-6-0-open-failed-eacces-permission-denied](http://stackoverflow.com/questions/33030933/android-6-0-open-failed-eacces-permission-denied) – Vall0n Oct 06 '16 at 11:22
  • AFAIK I don't need any permissions to read from a ContentResolver. This code works well with many other apps issuing ACTION_SEND (galleries, google photos, etc..). – Gili Garibi Oct 06 '16 at 11:28
  • Since you mentioned this is a recent problem, this could be happening because of the new Android Marshmallow (6.0) permission model. Please take a look at this question: http://stackoverflow.com/questions/33030933/android-6-0-open-failed-eacces-permission-denied – Fábio Hiroki Oct 06 '16 at 11:36
  • Share from other apps works well for me on Marshmallow, while the share from FB fails both on Marshmallow and pre-Marshmallow. Anyway, there shouldn't be a permission issue while reading from a ContentResolver – Gili Garibi Oct 06 '16 at 11:53

1 Answers1

0

I believe this was solved in the latest update of the Facebook app because it started behaving ok on my app without any changes.

Gili Garibi
  • 416
  • 2
  • 13