Try this out
PackageManager packageManager = getPackageManager();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
List<ResolveInfo> resolvedInfoList = packageManager.queryIntentActivities(intent, 0);
for (ResolveInfo resolveInfo : resolvedInfoList) {
if (resolveInfo.activityInfo.packageName.startsWith(getString(R.string.whatsapp_package_name))) {
intent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
break;
}
}
intent.setPackage(getString(R.string.whatsapp_package_name));//com.whatsapp
String text = "Texto a ser compartilhado";
intent.putExtra(Intent.EXTRA_TEXT, text);
startActivity(intent);
It's good to check if the user has WhatsApp installed