【问题标题】:how can i send the Text and the picture(url) through mms in android我如何在android中通过mms发送文本和图片(url)
【发布时间】:2014-12-31 09:05:33
【问题描述】:

这是我尝试过的代码。我只是想通过彩信发送视频的文字和图片。但我只能发送文字,但图片没有附加。任何人都可以帮助我。我我是新手。

ivbMessage.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        try {
            imageModel = videoDetails.getVideoImagesList().get(0);
            imageUrl = imageModel.getUrl();
            System.out.println("*****" + imageUrl);

            Uri screenshotUri = Uri.parse(imageurl);
            Intent sendIntent = new Intent(Intent.ACTION_VIEW);
            sendIntent.putExtra("sms_body", imageUrl);
            sendIntent.putExtra(Intent.EXTRA_STREAM,screenshotUri);
            sendIntent.setType("Image/png");
            activity.startActivity(sendIntent);
        } catch (Exception e) {
            Toast.makeText(activity, "SMS faild, please try again later!", Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }
}

【问题讨论】:

    标签: android android-mms


    【解决方案1】:

    应该是:

    Intent sendIntent = new Intent(Intent.ACTION_SEND); // action must be SEND not VIEW
    sendIntent.putExtra("sms_body", "some text"); 
    sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url));
    sendIntent.setType("image/png");  // seems like you need write with little letter here
    

    所以在你的代码中你有错误的操作应该是ACTION_SEND 并且你的类型也是错误的。应该是"image/png"

    而且您的图片网址必须正确。

    【讨论】:

    • 它工作了..非常感谢你。我没有得到它,因为我在 setType 中犯了错误。
    • 它有什么作用?它从外部 url 发送带有自动加载图片的彩信?
    • 我不确定这个 url 到底是什么,没关系,我想,只是需要一些 uri,我只是写了一个如何正确使用意图的示例
    • 你最好问问user3849098,他在哪里用的
    最近更新 更多