Android: How to send message programmatically by using WhatsApp, WeChat?

前端 未结 5 1570
情歌与酒
情歌与酒 2020-12-02 17:58

How to use messaging in android application by using WhatsApp and WeChat?

Actually requirement is to send sms using WhatsApp and We

5条回答
  •  天涯浪人
    2020-12-02 18:14

    This should help to send message using whatsapp:

    public void sendWhatsAppMsg() {
    
        Intent waIntent = new Intent(Intent.ACTION_SEND);
        waIntent.setType("text/plain");
                String text = "testing message";
        waIntent.setPackage("com.whatsapp");
        if (waIntent != null) {
            waIntent.putExtra(Intent.EXTRA_TEXT, text);//
            startActivity(Intent.createChooser(waIntent, text));
        } else {
            Toast.makeText(this, "WhatsApp not found", Toast.LENGTH_SHORT)
                    .show();
        }
    
    }
    

提交回复
热议问题