android-smsmms
android-smsmms copied to clipboard
Cannot call transaction.sendNewMessage to send MMS using system sending without being the default Messaging app
If you construct a Message which should be sent as MMS with save
set to true, it will hit an error similar to #113 because it tries to write to the Outbox, which only the default messaging app should be able to do. https://github.com/klinker41/android-smsmms/blob/f6fa7d379444dc11d700fe6178b418bd76cfb88f/library/src/main/java/com/klinker/android/send_message/Transaction.java#L657-L661
This makes sense, since we did ask to save it.
If you construct the same Message with save
set to false, you will get a null pointer exception from https://github.com/klinker41/android-smsmms/blob/f6fa7d379444dc11d700fe6178b418bd76cfb88f/library/src/main/java/com/klinker/android/send_message/Transaction.java#L662-L664 since existingMessageUri
is null.
It looks like the save == false
path is implementation-specific for the messaging apps which use this library, since it seems to assume that either this is a message which is a new message or this is a message which is an update to an existing message. Since I don't have any experience with the fully-fledged SMS apps which use this library, I don't feel confident in making a patch to make this behavior work for the case where I want to request the system-default messsaging app to send an MMS message for me.
My gut feeling is that it would require adding an else if
block to check if this is intended to be an updated to an old message (existingMessageUri != null
, or something), and then moving a bunch of the following code into that block, since a great deal of it is not needed for calling the SmsManager.SendMultimediaMessage
As an example of how to do it differently, I have copy-pasted a bunch of this library's logic into KDE Connect's SMS handling: https://invent.kde.org/network/kdeconnect-android/-/merge_requests/217 -- This still uses a lot of this library's internals (android.mms.pdu_alt
package especially), so I hope it is very understandable to a developer of this library.