
private fun shareNote(title: String, description: String, imageUriList: MutableList) {
val shareIntent: Intent = Intent().apply {
action = Intent.ACTION_SEND_MULTIPLE
putExtra(Intent.EXTRA_SUBJECT, title)
putExtra(Intent.EXTRA_TEXT, "$title\n\n$description")
type = if (imageUriList.isNotEmpty()) "image/*" else "text/plain"
if (imageUriList.isNotEmpty()) {
val uriList = ArrayList()
imageUriList.forEach { uriString ->
val uri = Uri.parse(uriString) // Adjust if these URIs are not parsed correctly
uriList.add(uri)
}
putParcelableArrayListExtra(Intent.EXTRA_STREAM, uriList)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
}
try {
startActivity(Intent.createChooser(shareIntent, "Share Note"))
} catch (e: Exception) {
e.printStackTrace()
requireContext().showToastShort("Sharing failed")
}
}
Я хочу поделиться заметкой, содержащей такой текст и изображения, но когда я выбираю приложение, с которым хочу поделиться ею, приложение не открывается.
Я проверил списки, и все они в порядке
AndroidManifest.xml
android:authorities="com.notes.purenoteit.fileprovider"
android:name="androidx.core.content.FileProvider"
android:exported="false"
android:grantUriPermissions="true"
>
file_paths.xml
изображения uri
content://com.miui.gallery.open/raw/%2Fstorage%2Femulated%2F0%2FAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2FWhatsApp%20Images%2FIMG-20241125-WA0001.jpg
Подробнее здесь: https://stackoverflow.com/questions/792 ... nother-app
Мобильная версия