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.
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