I want to share the string on whatsapp with share button on dialog by using oncicklistener.can anybody help me out with this.
Asked
Active
Viewed 65 times
-3
-
http://stackoverflow.com/questions/9948373/android-share-plain-text-using-intent-to-all-messaging-apps – Jagadesh Seeram Oct 16 '15 at 12:55
-
the same way as we share links,I want to share a string which i will get from the user input. – Saurav Kumar Oct 16 '15 at 12:55
-
then take it from the user input then. – Jagadesh Seeram Oct 16 '15 at 12:56
-
I am taking the input and storing it in a string now i want this string to be shared on whatsapp with a share button. – Saurav Kumar Oct 16 '15 at 12:59
1 Answers
0
Inside your setOnclickListener
do something like this,
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "your string";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "your header text");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "your title"));
This is basically sending a short message with a subject line , body and a title.

Sash_KP
- 5,551
- 2
- 25
- 34
-
-
No. Just use the above code. Accept and upvote the answer if it solves your problem. – Sash_KP Oct 16 '15 at 13:11
-
String contents = intent.getStringExtra("SCAN_RESULT"); AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(contents); builder.setTitle("Auto Details"); – Saurav Kumar Oct 16 '15 at 13:18