使用android向spesific联系人发送whatsapp消息
我正在寻找发送whatsapp消息到spesific联系人,我尝试这个代码 但这对我不起作用 代码会打开spesific联系人,但不会发送消息使用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.
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);
}
可能重复的