My code for sending a file with an Intent doesn\'t work with all file sources and I could not find the solution yet:
My app is registered for opening files, so when
The problem was using getUriForFile for file system paths and also for File Provider paths that actually must be used with a content resolver, so the solution was following:
Uri uri;
if (ContentResolver.SCHEME_CONTENT.equals(fileUri.getScheme())) {
uri = new Uri.Builder()
.path(fileUri.getPath())
.authority(fileUri.getAuthority())
.scheme(ContentResolver.SCHEME_CONTENT)
.build();
} else {
uri = getUriForFile(context, "com.myapp.fileprovider", new File(fileUri.getPath()));
}