How to share Image and text both together on WhatsApp to a specific recipient?

倾然丶 夕夏残阳落幕 提交于 2020-01-25 08:07:55

问题


I am trying to send image and text to whatsapp directly to specific recipient, but only text is send

    String msg = "Message here";
    Uri bitmapUri= Uri.parse(imageUrl);
    Uri uri = Uri.parse("http://api.whatsapp.com/send?phone="+smsNumber +"&text="+msg);

    try {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setData(Uri.parse(uri+"?image="+bitmapUri));
        startActivity(intent);

    } catch(Exception e) {
        Toast.makeText(this, "Error/n" + e.toString(), Toast.LENGTH_SHORT).show();
    }

回答1:


please visit this answer How to Send a Text message and Image through Whatsapp from Own Application with help of Intent in Android?




回答2:


You can send image using this code.

Uri uri = Uri.parse("android.resource://com.example.test/drawable/image_1");
                sharingIntent.setType("image/jpg"); 
                sharingIntent.putExtra(Intent.EXTRA_STREAM, uri); 
                startActivity(Intent.createChooser(sharingIntent, "Share image using"));


来源:https://stackoverflow.com/questions/57586074/how-to-share-image-and-text-both-together-on-whatsapp-to-a-specific-recipient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!