I am trying to send some message to whatsapp using the following code but it gives error android system has stopped but the intent is working fine. and the text is also added in the message. What could be the problem?
PackageManager pm = getPackageManager();
try {
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
String text = " http://play.google.com/ ";
PackageInfo info = pm.getPackageInfo("com.whatsapp", PackageManager.GET_META_DATA);
waIntent.setPackage("com.whatsapp");
waIntent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(Intent.createChooser(waIntent, "Share with"));
} catch (PackageManager.NameNotFoundException e) {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}