In my Andoroid app I want to let the user send a file that my app has generated using whatever sending method the user prefers (e.g. Email, Skype, Viber, Bluetooth, etc) I am using Intent.ACTION_SEND as follows:
File readF = new File(fullFileName);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.some_subject));
intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.some_message_body));
Uri uri = FileProvider.getUriForFile(this, "my.package.fileprovider", readF);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(intent, getResources().getString(R.string.some_info_message));
Which successfully sends files over Gmail, and Bluetooth, just as expected.
But when the user chooses Skype, the file is sent, but its name is changed
When the user chooses Viber nothing is sent.
If I change only the way I construct the Uri:
Uri uri = Uri.fromFile(new File("/some/publicly/available/file"));
Then the file is successfully sent both over Skype, and Viber, and the name is preserved.
So what is the difference in using FileProvider vs directly using a public file in Intent.