Android intent to share on WhatsApp

You can use Intent in Java code to share text via WhatsApp.
Intent whatsappIntent = new Intent(Intent.ACTION_SEND);
whatsappIntent.setType("text/plain");
whatsappIntent.setPackage("com.whatsapp");
whatsappIntent.putExtra(Intent.EXTRA_TEXT, "text to share on WhatsApp");
try {
startActivity(whatsappIntent);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this,"No WhatsApp application installed on this device", Toast.LENGTH_LONG).show();
}
See you in a next post about Android Code Snippets
Comment via Facebook
0 Comment via Google

0 تعليقات:

Post a Comment