是否可以从存储在数据库中的号码发送whatsapp(SQLite) 所以我已经尝试从较旧的帖子发送一个whatsapp但它发送ony消息或只打开联系人当我结合两者我没有得到任何结果 //这将在Whatsapp上打开特定联系人
void openWhatsappContact() {
String number = "919033152265";
Uri uri = Uri.parse("smsto:" + number);
Intent i = new Intent(Intent.ACTION_SENDTO, uri);
i.setPackage("com.whatsapp");
startActivity(Intent.createChooser(i, ""));
}
//这将发送特定消息到WhatsAPP
public void SelectContactAndMsgSend(View view) {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
waIntent.setPackage("com.whatsapp");
if (waIntent != null) {
waIntent.putExtra(Intent.EXTRA_TEXT, text);//
startActivity(Intent.createChooser(waIntent, "Share with"));
} else {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}
}
//两者都没有得到任何结果
public void CombiningBoth(View view) {
String number = "Here GOes My Number"; //As i am from india my number Im putting is 91xxxxxxxxxx
Uri uri = Uri.parse("smsto:" + number);
Intent waIntent = new Intent(Intent.ACTION_SENDTO, uri);
waIntent.setType("text/plain");
String text = "YOUR TEXT HERE";
waIntent.setPackage("com.whatsapp");
if (waIntent != null) {
waIntent.putExtra(Intent.EXTRA_TEXT, text);//
startActivity(Intent.createChooser(waIntent, ""));
} else {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}