Cannot send MMS?

霸气de小男生 提交于 2019-11-27 08:40:48

问题


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.

来源:https://stackoverflow.com/questions/47448316/cannot-send-mms

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!