将图像和文本发送到未保存的号码whastapp

时间:2019-04-29 17:22:51

标签: android

我想直接将图像和文本发送到whatsApp上的转换。我设法为数字打开了未保存的转换,但内容为空

这是我的代码

    public void onClickApp(Bitmap bitmap) {

    ByteArrayOutputStream bytes = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
    String path = MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, "Title", null);
    Uri imageUri = Uri.parse(path);

    String phone = Const.getInstance().getData().getNumber().trim();
    Intent sendIntent = new Intent("android.intent.action.MAIN");
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.setComponent(new ComponentName("com.whatsapp", "com.whatsapp.Conversation"));
    sendIntent.setType("image/*");
    sendIntent.putExtra(android.content.Intent.EXTRA_STREAM, imageUri);
    sendIntent.putExtra("jid", phone + "@s.whatsapp.net");
    sendIntent.putExtra(Intent.EXTRA_TEXT, "#"+Const.getInstance().getData().getTransactionCode()+" *"+Const.getInstance().getData().getNames()+"* \n"+
    "#Order "+Const.getInstance().getData().getReferenceNumber());
    sendIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(sendIntent);


}

This is the conversation that I have openned

0 个答案:

没有答案