fix FileUriExposedException

This commit is contained in:
Chumva 2018-05-21 11:45:21 +03:00
parent 4fe57fdfd1
commit 1f209acf28
2 changed files with 5 additions and 3 deletions

View file

@ -25,6 +25,7 @@ import android.os.StatFs;
import android.provider.MediaStore;
import android.support.annotation.NonNull;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.FileProvider;
import android.support.v7.app.AlertDialog;
import android.view.Display;
import android.view.KeyEvent;
@ -1878,7 +1879,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void playRecording(final Context ctx, final Recording r) {
if (r.isVideo()) {
Intent vint = new Intent(Intent.ACTION_VIEW);
vint.setDataAndType(Uri.fromFile(r.file), "video/*");
vint.setDataAndType(FileProvider.getUriForFile(mapActivity,"net.osmand.plus.fileprovider",r.file), "video/*");
vint.setFlags(0x10000000);
try {
ctx.startActivity(vint);
@ -1888,7 +1889,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return;
} else if (r.isPhoto()) {
Intent vint = new Intent(Intent.ACTION_VIEW);
vint.setDataAndType(Uri.fromFile(r.file), "image/*");
vint.setDataAndType(FileProvider.getUriForFile(mapActivity,"net.osmand.plus.fileprovider",r.file), "image/*");
vint.setFlags(0x10000000);
ctx.startActivity(vint);
return;

View file

@ -15,6 +15,7 @@ import android.os.Handler;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.FileProvider;
import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ActionMode;
@ -1410,7 +1411,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final Uri fileUri = Uri.fromFile(gpxInfo.file);
final Uri fileUri = FileProvider.getUriForFile(getMyApplication(),"net.osmand.plus.fileprovider", gpxInfo.file);
final Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
sendIntent.setType("application/gpx+xml");