Пример кода:
Код: Выделить всё
File file = new File("/storage/emulated/0/test.txt");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "text/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent); // Crashes on this line
android.os.FileUriExposeException:
файл :///storage/emulated/0/test.txt доступен за пределами приложения через
Intent.getData()
< strong>Изменить:
При настройке Android Nougat URI file:// больше не допускаются. Вместо этого нам следует использовать URI content://. Однако моему приложению необходимо открывать файлы в корневых каталогах. Есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/382 ... xt-exposed