Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用android向spesific联系人发送whatsapp消息_Android_Whatsapp - Fatal编程技术网

使用android向spesific联系人发送whatsapp消息

使用android向spesific联系人发送whatsapp消息,android,whatsapp,Android,Whatsapp,我正在寻找发送whatsapp消息到spesific联系人,我尝试这个代码 但这对我不起作用 代码会打开spesific联系人,但不会发送消息 String message="at first"; try { Uri uri = Uri.parse("smsto:"+"+999999999"); Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri); //sendIntent.setAction(Intent.

我正在寻找发送whatsapp消息到spesific联系人,我尝试这个代码 但这对我不起作用 代码会打开spesific联系人,但不会发送消息

String message="at first";
try {
    Uri uri = Uri.parse("smsto:"+"+999999999");
    Intent sendIntent = new Intent(Intent.ACTION_SENDTO, uri);
    //sendIntent.setAction(Intent.ACTION_SEND);
    //sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
    //sendIntent.setType("text/plain");
    sendIntent.setPackage("com.whatsapp");
    if sendIntent!= null) {
        sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
        startActivity(sendIntent);
    }else{
        Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT).show();
    }
    message="done";
}catch(Exception ex){
    message="Error: "+ex.toString();
}finally{
    TextView mas = (TextView) findViewById(R.id.mas);
    mas.setText(message);
}
可能重复的