通过WhatsApp的或Facebook分享图片和文字 [英] Share image and text through Whatsapp or Facebook

查看:1160
本文介绍了通过WhatsApp的或Facebook分享图片和文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序共享按钮,我想分享的图片,并在同一时间的文本。在Gmail中工作正常,但在WhatsApp的只发送的图像和Facebook的应用程序崩溃。我一直在寻找通过网络,显然这是不可能做到或者我没有看很好。

I have in my app a share button and i want to share an image and a text at the same time. In GMail works fine but in WhatsApp only sent the image and in Facebook the app crashes. I've been searched by the web and apparently it is impossible to do or I have not looked well.

在code I用于共享是这样的:

The code i use to share is this:

Intent shareIntent = new Intent(Intent.ACTION_SEND);  
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Message");         

Uri uri = Uri.parse("android.resource://" + getPackageName() + "/drawable/ford_focus_2014");
     try {
        InputStream stream = getContentResolver().openInputStream(uri);
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

如果我用shareIntent.setType(* / *),Facebook和WhatsApp的崩溃。

If I use "shareIntent.setType("*/ *")" Facebook and WhatsApp crashes.

有没有一些方法来做到这一点?也许发送两个消息由单独在同一时间(WhatsApp的)。

Is there some way to do this? Maybe sent two messages by separate at the same time (WhatsApp).

在此先感谢。

推荐答案

这是不可能的,因为WhatsApp的不支持与图片和文字在他们的消息。消息可以由单个图像,文本顺序,音频文件,联系人或视频。你不能有任何这些的组合。

This is not possible, as WhatsApp does not support messages with both pictures and text in them. A message may consist of a single image, text sequence, audio file, contact or video. You cannot have a combination of any of those.

而美国可以使用共享文本

Rather u can share your text using

    Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
    whatsappIntent.setType("text/plain");
    whatsappIntent.setPackage("com.whatsapp");
    whatsappIntent.putExtra(Intent.EXTRA_TEXT, "The text you wanted to share");
    try {
        activity.startActivity(whatsappIntent);
    } catch (android.content.ActivityNotFoundException ex) {
        ToastHelper.MakeShortText("Whatsapp have not been installed.");
    }

这篇关于通过WhatsApp的或Facebook分享图片和文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆