Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot call transaction.sendNewMessage to send MMS using system sending without being the default Messaging app #182

Open
sredman opened this issue Nov 2, 2020 · 0 comments

Comments

@sredman
Copy link

sredman commented Nov 2, 2020

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.

if (save) {
// this will be the default behavior if we do not explicitly set the save flag to false
PduPersister persister = PduPersister.getPduPersister(context);
messageUri = persister.persist(sendReq, Uri.parse("content://mms/outbox"),
true, settings.getGroup(), null, settings.getSubscriptionId());

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

} else {
messageUri = existingMessageUri;
Log.v(TAG, messageUri.toString());
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant