【问题标题】:Sending image via WhatsApp to specific recipient (Android)通过 WhatsApp 将图像发送给特定的收件人 (Android)
【发布时间】:2013-06-24 21:09:55
【问题描述】:

我正在通过 WhatsApp 分享我的图片 - 但我必须选择收件人。 这是我的代码:

   public static void shareImage(Context context,String path, String text, String otherAppPackage){
        Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("image/*");

        share.setPackage("com.whatsapp");

        share.putExtra(android.content.Intent.EXTRA_SUBJECT,  getSubject(context));
        if (text!=null){
            share.putExtra(Intent.EXTRA_TEXT,text);
        }
        if (path!=null){
            share.putExtra(Intent.EXTRA_STREAM,
                    Uri.fromFile(new File(path)));
        }
        context.startActivity(Intent.createChooser(share, context.getString(R.string.share_via)));
    }

我想直接与某人分享。你们中的一些人知道我该怎么做吗? 谢谢

【问题讨论】:

标签: android whatsapp


【解决方案1】:

您可以使用Intent.ACTION_SENDTO,但消息不会复制到剪贴板:

Uri uri = Uri.parse("smsto:+123456789");
Intent it = new Intent(Intent.ACTION_SENDTO, uri);
it.setPackage("com.whatsapp");
it.putExtra("sms_body", "The SMS text");
it.putExtra("chat",true);
startActivity(it);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-13
    • 2020-01-04
    • 1970-01-01
    相关资源
    最近更新 更多