Когда я пытаюсь поделиться файлом, открывается окно выбора, и если я выбираю WhatsApp, я могу вижу контакт, и когда я нажимаю на контакт, с которым хочу поделиться, я получаю всплывающее сообщение: «Не удалось поделиться, повторите попытку».
Это мой провайдер
Код: Выделить всё
android:name="androidx.core.content.FileProvider"
android:authorities="com.MyCompany.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
Код: Выделить всё
Код: Выделить всё
public void ShareFile(String fileName){
try {
File imagePath = new File(getFilesDir(), "SaveFiles");
File file = new File(imagePath,fileName);
Uri uri = FileProvider.getUriForFile(this, "com.MyCompany.fileprovider", file);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
shareIntent.setType("text/plain");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "Share File"));
}catch (Exception e){
Log.d(TAG, "ShareFile: " + e.getMessage());
ShowMessage(e.getMessage());
}
}
Подробнее здесь: https://stackoverflow.com/questions/710 ... oid-studio