private void chooseEditorAndOpenFileForNAndAbove() { Uri uri = FileProvider.getUriForFile(this, PROVIDER_AUTHORITY, mFileFragment.getFile()); String mimeType = FsUtils.getMimeType(uri.toString()); Intent editIntent = new Intent(Intent.ACTION_EDIT); editIntent.setDataAndType(uri, mimeType); editIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); try { startActivity(editIntent); forwardTransition(); } catch (ActivityNotFoundException e) { showMessageDialog(R.string.dialog_error_title, getString(R.string.error_no_edit_app)); } }
private void chooseEditorAndOpenFileForMAndBelow() { Uri uri = Uri.fromFile(mFileFragment.getFile()); String mimeType = FsUtils.getMimeType(uri.toString()); Intent viewIntent = new Intent(Intent.ACTION_VIEW); Intent editIntent = new Intent(Intent.ACTION_EDIT); viewIntent.setDataAndType(uri, mimeType); editIntent.setDataAndType(uri, mimeType); try { Intent chooserIntent = Intent.createChooser(viewIntent, getString(R.string.label_choose_app_to_edit)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { editIntent }); startActivity(chooserIntent); forwardTransition(); } catch (ActivityNotFoundException e) { showMessageDialog(R.string.dialog_error_title, getString(R.string.error_no_edit_app)); } }
return true; Uri uri = Uri.fromFile(mFileFragment.getFile()); String mimeType = FsUtils.getMimeType(uri.toString()); Intent viewIntent = new Intent(Intent.ACTION_VIEW);