-2

I am developing an inspirational quotes application and I want my users to share the quotes they see before them to other applications(Such as Twitter,facebook,whatsapp,etc) if they click on the share button or the menu share button, it should automatically picks the text on that Interface, not me inputting one particular text because the texts varies base on the particular interface the user is viewing the code.(I am using a recycler view and view pager with holders and adpaters so the user scroll down on one page) please help me with the code.

1 Answers1

0

try this code

Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");

sharingIntent.putExtra(Intent.EXTRA_TEXT, text);  //Add your quote here
sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "From Your Application"); //Add a Subject here

startActivity(Intent.createChooser(sharingIntent, "Share via.."));
Arun Shankar
  • 2,603
  • 2
  • 26
  • 36