Android button to share text from textview - android

I need the share button to share the text in the textView in this way,I am a beginner in java and android

on Button Click
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,"Your score and Some extra text");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "The title");
startActivity(Intent.createChooser(shareIntent, "Share..."));

create a method which will be called on share button and add this lines in it
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
startActivity(Intent.createChooser(sharingIntent, "Share via"));
Try this link as well.
Cheers

Take a look at how to use the Intent that launches the Share Via dialog.
See this post that has your answer :
Android Share Via Dialog

Here is a complete tutorial for this. http://mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/

Related

Android - Chooser dialog for sharing -- different intents depending on application selected?

I'd like to share different information depending on the application selected by the user. For example, I'd like to send shorter text to Twitter than I do Gmail (otherwise, I go over in characters). Is there anyway to achieve this? Bonus question, is it possible to make hyperlinks via sharing via Gmail or SMS. For example, "Download here" where 'here' is a link instead of "Download by clicking the link below: http://..."
Current code:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, getTextToShare(data));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));
To find the selected share target this could be interesting for you: Branching the Android Share Intent extras depending on which method they choose to share
By using below code may helps you:
String shareText="Download <a href='[download link]'>here</a>";
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, Html.toHtml(shareText));
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_SUBJECT, data.getTitle());
startActivity(Intent.createChooser(shareIntent, "Share this story"));
Share Url Links and Texts into Social Networks (Facebook,Twitter and linkedin)

How to set different share in the same shareButton

I am stuck in my app trying to set a share button.
I have a simple textview to be shared with a few of social networks.
As i found out i cannot share just text with Facebook without using Facebook SDK.
Now i d like to know if is possibile to set a thing like. If user press whatsapp share my string if user press Facebook share the link of my app.
Below is my share button code.
case R.id.action_share:
Intent intent2=new Intent(Intent.ACTION_SEND);
intent2.setType("text/plain");
intent2.putExtra(Intent.EXTRA_TEXT, random + "\n"+"By Random Quotes" ); //random is the textview
startActivity(Intent.createChooser(intent2, "Share via"));
break;
you have to start activity with new task,like this:-
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
share.putExtra(Intent.EXTRA_SUBJECT, "share discription");
share.putExtra(Intent.EXTRA_TEXT,"text you want to share");
startActivity(Intent.createChooser(share,"you share title"));
}

how to share available content in textview using share option

I have developed an application. In this application, content is coming from database. The content I am getting in my textview , I just want to share the whole content using email etc..
How can I just send i.e share my available content.
I am getting all sharing options, but I am not able to share the content coming on screen.
Please let me know if you want more info!
Kindly Help me!
Thanks in Advance!
It's very simple. You just need to put in your intent.
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"yourEmail#gmail.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email Subject");
emailIntent.putExtra(Intent.EXTRA_STREAM,yourTextView.getText());
emailIntent.setType("text/html");
startActivity(emailIntent);
Firstly, you should obtain the text that you want to share. Secondly, you can use an intent in order to show to the user the different ways to share the content. You can use this code to achieve it:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, textFromTextView);
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent,
"Share with..."));
I think AndroidWarrior's answer will only allow you to use e-mail but It's correct.

How to add Facebook Share button in Android Application

I am beginner in android.I want to add FacebookShare button in my android application.I create the app in 2.2 .please help me
I use this code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getStri‌​ng(R.string.title_activity_android_face_book_share));
emailIntent.putExtra(android‌​.content.Intent.EXTRA_TEXT,getResources().getString(R.string.title_activity_android_face_book_share));
startActivity(emailIntent);
I Use the following link also Best way for social sharing in Android
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "URLyouWantToShare");
startActivity(Intent.createChooser(shareIntent, "Share..."));
Use the ACTION_SEND Intent, add the URL you want to share. User will be given a selection of apps to accept the share intent such as facebook etc.

Android:not getting proper text when sharing with inbuilt applications

I used the following code.
Intent share = new Intent(android.content.Intent.ACTION_SEND);
share.setType("text/plain");
share.putExtra(Intent.EXTRA_SUBJECT, subject);
share.putExtra(
Intent.EXTRA_TEXT,
"i have just visited http://www.google.com");
startActivity(Intent.createChooser(share,
"Share Sydneyho! with your friends via"));
When i select gmail its showing what is written in Intent.EXTRA_TEXT but when i am selecting facebook its entirely different message and i don't know from where its comes from.
please help!
I have used the following code snippet to share Message with Action_Send to other apps.
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra("android.intent.extra.SUBJECT", "");
sharingIntent.putExtra("android.intent.extra.TEXT", "ABC");
startActivity(Intent.createChooser(sharingIntent, "Share using"));
And it works fine in my device(Android 2.2).
Conceptually I dont know what is different between your code and above.
But the above code works fine for me.
Got some similar posts here at stackoverflow and come to this conclusion we cant pass text
in
share.putExtra(Intent.EXTRA_TEXT,"bla bla bla");
to make it visible on facebook share page but we have to pass link to a website.

Categories

Resources