我發現了一些通過whatsapp發送消息的代碼。事情是這樣的:
通過whatsapp使用Intent發送消息
Button send=(Button)findViewById(R.id.sendbtn);
EditText input=(EditText)findViewById(R.id.inputtxt);
final String txt=input.getText().toString();
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent sendIntent=new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT,txt);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
}
});`
的代碼工作,但在WhatsApp的屏幕顯示了,我選擇一個聯繫人,我WhatsApp的關閉和我的應用程序顯示出來。還有什麼要添加發送消息?