Skip to content

Instantly share code, notes, and snippets.

@amitittyerah
Created April 12, 2014 11:17
Show Gist options
  • Save amitittyerah/10530694 to your computer and use it in GitHub Desktop.
Save amitittyerah/10530694 to your computer and use it in GitHub Desktop.
Share via WhatsApp for Android
class WhatsAppShare extends ShareManager
{
public WhatsAppShare(Context context)
{
super(context);
}
public void shareViaWhatsApp(String msg)
{
Intent whatsAppIntent = new Intent(Intent.ACTION_SEND);
whatsAppIntent.setType("text/plain");
whatsAppIntent.setPackage("com.whatsapp");
if (whatsAppIntent != null) {
whatsAppIntent.putExtra(Intent.EXTRA_TEXT, msg);//
startActivity(Intent.createChooser(whatsAppIntent, "Share with"));
} else {
Toast.makeText(this, "WhatsApp not Installed", Toast.LENGTH_SHORT)
.show();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment