Android:not getting proper text when sharing with inbuilt applications - android

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.

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)

Android Share intent - issue with Facebook

I need to share text and one image from my application via a share intent. I read this article. I thought it would be easy to create share intent. But it is not so easy, because there is a problem with sharing via Facebook.
I need to share some text and one image, which is stored in device. My first attempt looked like this:
The first try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("image/jpg");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
I tried this code and in applications like Gmail, Google+, Google Keep, etc, everything works fine. But Facebook did not work fine.
There is no my text ("My custom text...") in this screenshot. So I have tried something else.
The second try
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File("/sdcard/img.jpg")));
shareIntent.putExtra(Intent.EXTRA_TEXT, "My custom text...");
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent, getString(R.string.label_share)));
And the result of this is here:
There is no text and also no image in this screenshot.
I also tried to change type to image/* and */*, but it did not help. I do not know what is wrong. I just need to share some text and image via Facebook. The first try works well for other applications, but for Facebook not.
Can someone help me, please?
Your first attempt is OK, Facebook does not allow sharing text this way, they say "Pre-filling these fields erodes the authenticity of the user voice."

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.

Facebook share can't get the text

I want to make tweet/share buttons for gamers. They will make them able to write some tweets or share the gained score in the wall.
I found this code:
String shareBody = "Share text";
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Test"));
This code is quite good.
For the Twitter app, the text is sent correctly. ("Share text")
But it doesn't work for the facebook app.
Where is the error?
Thanks in advance!
You have no error - it's simply impossible.
Facebook is limiting the "share via intent" to display only the hyperlinks if exists. you can't display any regular text.
The only way to do that is to make a full facebook connect (Facebook's Android SDK) and ask post-to-wall permissions from user.

Android: action_send intent is not showing facebook

I recently implemented the action-send intent to share a plain text. Facebook is installed and updated on my phone but only "Googlemail" and "Textmessage" are shown as options for sharing my text.
A short code snippet:
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("plain/text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, item.getTitle());
intent.putExtra(
android.content.Intent.EXTRA_TEXT,
(item.getDescription());
startActivity(Intent.createChooser(intent, "Send..."));
Any suggestions what's wrong with my app?
Normally I would think that I dont have to implement the whole facebook sdk for my simple purpose?!
Thanks in advance
The MIME type to use is text/plain, not plain/text.

Categories

Resources