问题
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