Android:在SDCard上发送带有图片的彩信

时间:2012-05-10 04:31:57

标签: android mms

嗨所以我正试图在彩信中从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)

1 个答案:

答案 0 :(得分: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);

希望这有助于某人