GeoPapa
GeoPapa

Reputation: 129

On Android MMS message keeps on being received

I'm trying to create an app that will handle SMS and MMS functionality and act as the default app.

In order to send MMS I use klinker's API https://github.com/klinker41/android-smsmms

I store the sent MMS to the phone using content provider (create dummy SMS, create MMS its MMS part and at the end, I delete the dummy SMS)

When I receive an MMS through broadcaster service and store the MMS at inbox I should send something back to the carrier?

Because the phone receives again after a day or two the same MMS.

Upvotes: 0

Views: 228

Answers (1)

JamisonMan111
JamisonMan111

Reputation: 200

I have erased my old answer and possibly have some more info for you if you are still concerned.

I found I ran into a very similar problem with some but not all phones that send to me an Mms message. Ok so when I receive the Mms, there is something you could and probably should send back to the phone that sent you the message.

What you send back is called an: "AcknowledgeInd". AcknowledgeInd is a public class that extends "GenericPdu". This AcknowledgeInd is found online or inside the Klinker Library if you dig through it.

There is also some very dry and boring official stuff online about what an AcknowledgeInd actually is along with ReadRecInd and all the others, if you are interested.

You would need to build this AcknowledgeInd and send it back a Mms message to whomever sent your device the message.

Build Ack Ind:

        ack_ind = new AcknowledgeInd(mms_version, pdu_trans_ID.getBytes());

        return new PduComposer(application_context, ack_ind).make();

PduComposer.make() returns a byte[] which you then use to send Mms.

    /*"mms_send_file" is created here and used only inside of sendMmsViaCarrier();
     * It is then deleted inside handleSmsMmsSent() after the Mms has been sent whether
     *   successful or not*/
    final String mms_file_name = "send." + String.valueOf(Math.abs(new Random().nextLong())) + ".dat";
    File mms_follow_up_file = new File(application_context.getCacheDir(), mms_file_name);

FileOutputStream the byte[] to "mms_follow_up_file".

Build the Uri to use as argument in the method sms_manager.sendMultimediaMessage().

    Uri content_uri = (new Uri.Builder())
            //.authority("com.example.android.apis.os.MmsFileProvider")
            //.authority(getBaseContext().getPackageName() + ".MmsFileProvider")
            .authority(application_context.getPackageName() + ".MmsFileProvider")
            .path(mms_file_name)
            .scheme(ContentResolver.SCHEME_CONTENT)
            //.scheme(ContentResolver.SCHEME_FILE)  
            .build();

Then call Android method to send:

    sms_manager.sendMultimediaMessage(application_context, content_uri, null, null, pending_intent_mms_follow_up);

NOTES:

Always use "ApplicationContext" for this Mms stuff. You are gonna need the "Transaction ID" that is available as part of the NotificationInd which is what is retrieved and made available to you by Android upon receiving the Broadcast from your Manifest Receiver.

Upvotes: 0

Related Questions