Sending message through whatsapp using Intent
<p>I found some code for sending message through whatsapp. Something like this:
<br>  </p>

<pre><code>    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);



        }
    });`
</code></pre>

<p>The code is working but when the whatsapp screen shows up and i select a contact, my whatsapp closes and my application shows up. Is there anything else to be added to send a message?</p>