Unable to send MMS using SmsManager

邮差的信 提交于 2019-11-29 05:21:06
marmor

The flow should be as such:

  1. Create the Mms send-request - new SendReq() and config its date, body, to, etc.
  2. Create the Mms body - new PduBody().
  3. Create Parts via new PduPart() for each attachment, and add to the body: body.addPart(pdu)
  4. Add the body to the request - req.setBody(body)
  5. Convert the send-request to a byte[] ready to be sent by calling new PduComposer(context, mySendReq).make() - note that you'll need to copy lots of code from Android's source code to get the PduComposer class.
  6. Now's the interesting part - you save the byte[] to a local file accessible to your app only, and add ContentProvider class that allows other apps to request access to your file, this is MmsFileProvider class in the sample app, don't forget to declare your provider in your manifest file.
  7. Now, when you call the SmsManager.sendMultimediaMessage api, your file provider will wake up to serve the file containing the pdu bytes to the system SmsManager that will read it and send it on the wire.

Having that said, this API is only working for me on some devices (e.g. Nexuses), but not on some others (e.g. HTC One). See my SO question here: SmsManager MMS APIs on HTC/LG

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