Skip to content

Commit

Permalink
fix(android): Avoid SecurityError on Android 10 file share (#3655)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Oct 9, 2020
1 parent 1382c9f commit 1c47e15
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.webkit.MimeTypeMap;

import androidx.core.content.FileProvider;
Expand Down Expand Up @@ -50,6 +51,10 @@ public void share(PluginCall call) {
intent.setType(type);
Uri fileUrl = FileProvider.getUriForFile(getActivity(), getContext().getPackageName() + ".fileprovider", new File(Uri.parse(url).getPath()));
intent.putExtra(Intent.EXTRA_STREAM, fileUrl);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
intent.setData(fileUrl);
}
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
}

if (title != null) {
Expand Down

2 comments on commit 1c47e15

@danielehrhardt
Copy link

@danielehrhardt danielehrhardt commented on 1c47e15 Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am building my App with Sdk Version 28 it has several reasons.
Now am getting the following error:
image
Should i create a new Issue?

@jcesarmobile
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, sorry, we won't do fixes because users use old targetSDK values. If we allow users to configure it is in case they want to use latest before we officially do, not to use old ones.

Please sign in to comment.