在Android上MMS消息不断被接收

时间:2017-09-12 04:11:41

标签: android mms

我正在尝试创建一个可以处理短信和彩信功能的应用,并充当默认应用。

要发送彩信,请使用klinker的API https://github.com/klinker41/android-smsmms

我使用内容提供商将发送的MMS存储到手机中(创建虚拟短信,创建MMS的MMS部分,最后,我删除虚拟短信)

当我通过广播服务收到彩信并将彩信存入收件箱时,我应该将某些内容发回给运营商吗?

因为手机在一两天后再次收到相同的彩信。

1 个答案:

答案 0 :(得分:0)

我已经删除了我的旧答案,如果您仍然担心,可能会为您提供更多信息。

我发现我遇到了一个非常类似的问题,有些但不是所有手机都向我发送了Mms消息。好吧,当我收到Mms时,有一些你可以并且可能应该发送回给你发送信息的电话。

您发回的内容称为:" AcknowledgeInd"。 AcknowledgeInd是一个公共课 延伸" GenericPdu"。如果您仔细阅读,可以在线或在Klinker Library内找到此AcknowledgeInd。

如果你有兴趣的话,网上还有一些非常干燥和无聊的官方资料,关于AcknowledgeInd和ReadRecInd以及所有其他内容。

您需要构建此AcknowledgeInd并将Mms消息发回给向您的设备发送消息的任何人。

Build Ack Ind:

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

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

PduComposer.make()返回一个byte [],然后用它来发送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 byte [] to" mms_follow_up_file"。

构建Uri以在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();

然后调用Android方法发送:

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

注意:

始终使用" ApplicationContext"对于这个Mms的东西。 你需要"交易ID"这是作为NotificationInd的一部分提供的,这是Android从您的清单接收器接收广播后检索并提供给您的。