Cannot send MMS?
Asked Answered
B

0

1

I've been struggling to send an image file by MMS for the last two days. The crazy thing is, there are no crashes!

This code is in my service:

static Settings settings;
    public static void sendPicture(final byte [] data){
        final Bitmap bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
             new Thread(new Runnable() {
                 @Override
                 public void run() {

                ApnUtils.initDefaultApns(z, new ApnUtils.OnApnFinishedListener() { //Z is just an instance variable that stores context
                    @Override
                    public void onFinished() {
                        settings = Settings.get(z, true);
                    }
                });

                Settings settings = Settings.get(z); 
                com.klinker.android.send_message.Settings sendSettings = new com.klinker.android.send_message.Settings();
                sendSettings.setMmsc(settings.getMmsc());
                sendSettings.setProxy(settings.getMmsProxy());
                sendSettings.setPort(settings.getMmsPort());
                sendSettings.setUseSystemSending(true);
                Transaction transaction = new Transaction(z, sendSettings);
                Message message = new Message("This is my MMS!", "##########", bmp);
                transaction.sendNewMessage(message, Transaction.NO_THREAD_ID);

                Log.v("myTag", "Sent MMS!");

            }
        }).start();
    }

Because Android does not natively provide any API for MMS, I am using the Klinker api for sending MMS. However, I am more than happy to explore other ways to send MMS—I just want to send this image file!

Please let me know what you see wrong, or if I should approach this in a different way.

Bountiful answered 23/11, 2017 at 5:40 Comment(8)
1) Does your carrier/data plan that test device is using support MMS 2) Does the Klinker API sample work? 3) What device and OS are you testing on. [Given that Android API19 has a MMS api] 3) What size image are you trying to send.Callihan
@MorrisonChang 1) Yes, it does support MMS for sure. 2) I'm 100% sure that the Klinker API sample works, since apps like Pulse use it, but I'm not 100% sure I have implemented it correctly? 3) Unfortunately, I need my app to work for OS versions below API 19, so the modern MMS api isn't an option for me 4) The images are under 4mbBountiful
It should not be difficult to install and run the Klinker API sample with as few changes as possible to make sure that you have everything correct. Once that is done then you have a working version to make modifications. Also 4mb seems 'large' based on: android.stackexchange.com/questions/26804/…Callihan
@MorrisonChang I just created a method to resize my Bitmap to 100kb, and the MMS still is not being sent. As for the Klinker API, after running the sample, I noticed that it works after being set as the default messaging application. Is that necessary? (1) That's very odd and (2) I haven't read anything about needing to become the default messaging application in all the research that I've done.Bountiful
What I found: #19560823 and from the blog: android-developers.googleblog.com/2013/10/… and specifically Although the system writes sent SMS messages to the SMS Provider while your app is not the default SMS app, it does not write sent MMS messages and your app is not able to write to the SMS Provider for other operations, such as to mark messages as draft, mark them as read, delete them, etc.Callihan
@MorrisonChang Thank you for that, I guess that confirms the doubts that I had. In my app, I just want to send a quick MMS message from my background service without user interaction—but if I need to be the default SMS application to do that, then it won't work, since I'll have to prompt the user to select me. Not sure of any other workarounds besides for maybe uploading the image to a server and sending its link by SMS. What do you think I should do?Bountiful
@RuchirBaronia I've been stuck on receiving MMS for weeks. Have you been able to receive MMS?Dewy
@MorrisonChang Have you succeeded at receiving MMS using this library?Dewy

© 2022 - 2024 — McMap. All rights reserved.