0
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Mass Venture");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Download the Mass Venture Mobile Application to grab products with more offers. Use REFERENCE CODE:" + user_name);
shareIntent.setType("*/*");
startActivity(Intent.createChooser(shareIntent, "Refer & Earn"));

while choosing whatsapp it showing, sharing failed.How can I solve this problem?

sschrass
  • 7,014
  • 6
  • 43
  • 62
Jeeva V
  • 153
  • 1
  • 1
  • 9
  • 2
    Possible duplicate of [How to share text to WhatsApp from my app?](https://stackoverflow.com/questions/12952865/how-to-share-text-to-whatsapp-from-my-app) – AskNilesh Mar 26 '18 at 05:16
  • i want to share message using other sourses also(gmail, textmsg etc). With your mentioned code i can share only using whatsapp – Jeeva V Mar 26 '18 at 05:26
  • https://stackoverflow.com/questions/9948373/android-share-plain-text-using-intent-to-all-messaging-apps – AskNilesh Mar 26 '18 at 05:27

2 Answers2

0

Try this:

String shareText = "Enter the dummy text to share";
        Intent intent_share = new Intent();
        intent_share.setAction(Intent.ACTION_SEND);
        intent_share.putExtra(Intent.EXTRA_TEXT, shareText);
        intent_share.setType("text/plain");
        Intent.createChooser(intent_share, "Share via");
        startActivity(intent_share);
Liya
  • 568
  • 7
  • 28
0
                    Intent share = new Intent(android.content.Intent.ACTION_SEND);
                    share.setType("text/plain");
                    share.addFlags(Intent.FILL_IN_CATEGORIES);

                    share.putExtra(Intent.EXTRA_CC, "Title Here");

                    String message = " Your message text"


                    share.putExtra(Intent.EXTRA_TEXT, message);

                    startActivity(Intent.createChooser(share, "Share With"));
pravin maske
  • 72
  • 1
  • 13