安卓:发送MMS消息,图片上的SD卡(Android: Send MMS Message With

2019-06-24 07:28发布

嗨所以我尝试发送从SD卡的图像(PNG)在彩信中。 我使用的是ACTION_SEND意图,但它似乎并不奏效。

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Sent using Spootur");
sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imagePath));
startActivityForResult(sendIntent, SEND_ACTIVITY);

我知道的ImagePath具有/mnt/sdcard/Spootur/Pictures/6799abd6-df22-4017-89e1-d9e529790fd8.png的值,它指向现有的文件。

当选择菜单出现时,我选择我的即时通讯应用(Handcent),但它给了我一个“很抱歉,您不能将此图片添加到您的信息”的错误。 我尝试使用其他应用程序,以及铺天盖地的结果我得到的是,我给它的资源是一个“不支持的文件类型”。 我不知道为什么这可能发生,因为我明确地设置MIME类型为.png图像。

有任何想法吗? 这里有一些对于那些有麻烦各种应用程序的logcat的日志:

电子邮件:

05-10 00:29:35.752: W/ActivityManager(343): Trying to launch com.android.email/.activity.MessageCompose
05-10 00:29:35.962: I/Database(24487): sqlite returned: error code = 0, msg = Recovered 12 frames from WAL file /data/data/com.android.email/databases/webview.db-wal
05-10 00:29:35.972: I/Database(24487): sqlite returned: error code = 0, msg = Recovered 26 frames from WAL file /data/data/com.android.email/databases/webviewCache.db-wal
05-10 00:29:36.072: W/System.err(24487):    at com.android.email.activity.MessageCompose.addAttachment(MessageCompose.java:6886)
05-10 00:29:36.072: W/System.err(24487):    at com.android.email.activity.MessageCompose.addAttachment(MessageCompose.java:6750)
05-10 00:29:36.072: W/System.err(24487):    at com.android.email.activity.MessageCompose.addAttachment(MessageCompose.java:7112)
05-10 00:29:36.072: W/System.err(24487):    at com.android.email.activity.MessageCompose.initFromIntent(MessageCompose.java:9160)
05-10 00:29:36.072: W/System.err(24487):    at com.android.email.activity.MessageCompose.onCreate(MessageCompose.java:854)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.Email.startServiceIfNeed(Email.java:659)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.Email.isServiceConnected(Email.java:723)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.Email.callWhenServiceConnected(Email.java:791)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.Email.registerListener(Email.java:883)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.Email.registerListener(Email.java:879)
05-10 00:29:36.102: W/System.err(24487):    at com.android.email.combined.SevenUtils.addListener(SevenUtils.java:35)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Controller.addSevenListener(Controller.java:283)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Controller.addResultCallback(Controller.java:275)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.activity.MessageCompose.onResume(MessageCompose.java:2457)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Email.startServiceIfNeed(Email.java:659)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Email.callWhenServiceConnected(Email.java:797)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Email.registerListener(Email.java:883)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Email.registerListener(Email.java:879)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.combined.SevenUtils.addListener(SevenUtils.java:35)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Controller.addSevenListener(Controller.java:283)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.Controller.addResultCallback(Controller.java:275)
05-10 00:29:36.112: W/System.err(24487):    at com.android.email.activity.MessageCompose.onResume(MessageCompose.java:2457)
05-10 00:29:36.132: D/InputTransport(343): Input channel constructed: name='40710c08 com.android.email/com.android.email.activity.MessageCompose (server)', ashmemFd=288, receivePipeFd=336, sendPipeFd=328
05-10 00:29:36.132: D/InputTransport(343): Input channel constructed: name='40710c08 com.android.email/com.android.email.activity.MessageCompose (client)', ashmemFd=290, receivePipeFd=320, sendPipeFd=337
05-10 00:29:36.132: D/InputTransport(343): Input channel destroyed: name='40710c08 com.android.email/com.android.email.activity.MessageCompose (client)', ashmemFd=290, receivePipeFd=320, sendPipeFd=337
05-10 00:29:36.132: D/InputTransport(24487): Input channel constructed: name='40710c08 com.android.email/com.android.email.activity.MessageCompose (client)', ashmemFd=74, receivePipeFd=75, sendPipeFd=76
05-10 00:29:36.243: I/WindowManager(343):   CREATE SURFACE Surface(name=com.android.email/com.android.email.activity.MessageCompose, identity=1887, mNativeSurface=0) IN SESSION android.view.SurfaceSession@40a3fc10: pid=24487 format=-1 flags=0x0 / Window{40710c08 com.android.email/com.android.email.activity.MessageCompose paused=false}
05-10 00:29:36.353: I/ActivityManager(343): Displayed com.android.email/.activity.MessageCompose: +604ms

消息:

05-10 00:28:18.887: D/Mms/ConversationComposer(24350): [main][end]    initComposeMessage ------ 
05-10 00:28:18.917: V/Mms/ConversationComposer(24350): [main]getComposeMessageStatus(),state=0
05-10 00:28:18.917: V/Mms/ComposeMessage(24350): [main]initMessageList()
05-10 00:28:18.987: V/Mms/ComposeMessage(24350): [main]loadMessageContent()
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.MessageUtils.isAnimatedImage(MessageUtils.java:2265)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.data.WorkingMessage.setAttachment(WorkingMessage.java:601)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.ComposeMessage.addImage(ComposeMessage.java:6756)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.ComposeMessage.addMedia(ComposeMessage.java:6894)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.ComposeMessage.addMedia(ComposeMessage.java:6961)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.ComposeMessage.access$7500(ComposeMessage.java:198)
05-10 00:28:19.007: W/System.err(24350):    at com.android.mms.ui.ComposeMessage$45.run(ComposeMessage.java:4680)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.data.WorkingMessage.changeMedia(WorkingMessage.java:2202)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.data.WorkingMessage.setAttachment(WorkingMessage.java:658)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.ui.ComposeMessage.addImage(ComposeMessage.java:6756)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.ui.ComposeMessage.addMedia(ComposeMessage.java:6894)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.ui.ComposeMessage.addMedia(ComposeMessage.java:6961)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.ui.ComposeMessage.access$7500(ComposeMessage.java:198)
05-10 00:28:19.007: E/Mms/media(24350):     at com.android.mms.ui.ComposeMessage$45.run(ComposeMessage.java:4680)

Answer 1:

我最终找到了解决方案:它在寻找一个文件,而不是内容流或直URI。 这使得它为我工作:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra("sms_body", "Sent using Spootur");
sendIntent.setType("image/png");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
startActivityForResult(sendIntent, SEND_ACTIVITY);

希望这可以帮助别人



文章来源: Android: Send MMS Message With Picture on SDCard
标签: android mms