diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-08-25 22:41:33 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-08-26 22:28:58 +0200 |
commit | da12042acdb4fc94e542ff098e72fdc2618cc6b4 (patch) | |
tree | f98ea91cb1b16ac5e1e825839ec07422d22f7143 /src/main/java/de/pixart/messenger/ui/adapter | |
parent | 1fb9dcb42760d4fd8a94ffa0813eff38be91dd5b (diff) |
add file provider to share files on android n
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/adapter')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java index 4efdf6701..9b0f02696 100644 --- a/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java +++ b/src/main/java/de/pixart/messenger/ui/adapter/MessageAdapter.java @@ -12,6 +12,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; +import android.support.v4.content.FileProvider; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; @@ -804,7 +805,9 @@ public class MessageAdapter extends ArrayAdapter<Message> { if (mime == null) { mime = "*/*"; } - openIntent.setDataAndType(Uri.fromFile(file), mime); + Uri uri = FileProvider.getUriForFile(activity,"de.pixart.messenger.files",file); + openIntent.setDataAndType(uri, mime); + openIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); PackageManager manager = activity.getPackageManager(); List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0); if (infos.size() == 0) { |