Android Share Text on Facebook instead of Link - android

I am working on Text Sharing on From my Android Application . I have used the following code.
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String text="http://google.com";
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,text);
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Message");
startActivity(Intent.createChooser(sharingIntent, "Share using"));
If I will this code means it shares link correctly and shows like following image !
Attached Image
When I am using normal text like "sample content" means it is not accepting and showing the text .... I need to share the text instead of that link .. please help me ...
Its working correctly for Gmail and Twitter also.
Waiting for better response..... Thanks in Advance

This is a limitation with the (stupid) Facebook app. They know about it, but apparently don't want to fix it.
Your only option is to implement Facebook sharing using their API.

Related

How to share a link which is not visible to user

In my android app i want to share a Link to my website using intent but i dont want it to be visible to other user
example i want to share "smoe website link"
But to user it should look like "Click me to see it".
I tried this but wasnt successfull it just shows the simple text and was not clickable
<string name="app_link">Click me!</string>
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra("PostID", postID);
intent.putExtra("UserID", userID);
intent.putExtra(android.content.Intent.EXTRA_TEXT,activity.getString(R.string.app_link);
activity.startActivity(Intent.createChooser(intent, "Share"));
Any help will be really appreciated.
What you want is not realistically possible right now.
EXTRA_TEXT must always be interpreted as plain text by the receiving app. You could try using EXTRA_HTML_TEXT which was added with API 16. But many apps don't support HTML and will simply use EXTRA_TEXT instead (or not show any text at all if you omit EXTRA_TEXT).

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 make clicking on the item in "share" form with android espresso test

Trying to test the share function of the app, which is in the app it calls createChooser() to open the "sharing" chooser form.
startActivity(Intent.createChooser(sharingIntent, "Share something"));
Question is after the "sharing" chooser form is up how to simulate the clicking on some listed apps item, lets say there is app has description "AppName". Tried following it does not work, the chooser form stays there until the test timeout.
tried:
onView(withContentDescription("AppName"))
.perform(click());
and:
onView(withText("AppName"))
.perform(click());
Below is the example to share something in whatsapp:
Intent waIntent = new Intent(Intent.ACTION_SEND);
waIntent.setType("text/plain");
waIntent.setPackage("com.whatsapp");//package name of whatsapp
waIntent.putExtra(Intent.EXTRA_TEXT, "Share Something");//text to share
startActivity(Intent.createChooser(waIntent,"Share via..."));
I hope this might help you.

Share image from URL via Twitter app - Android

I'm trying to share some text and image via the Twitter app. The image source is a web url.
Below is my code:
sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url+"");
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.parse("http://example.com/images/thumbs/file_name.jpg"));
But only the text is getting shared via the Twitter app. I also get a message saying "Image could not be loaded". What is the problem with this code?
Sourav, I think you must download the picture before sharing it. You can do it manually, or maybe you could use a library like this. You can find inside the library's repository easy documentation about how to set up and use it.
After you have downloaded the picture you can follow this method:
private Intent shareIntent(String bookmark_url, String imagePath){
sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("*/*");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "I am reading this publication, check it out here: "+bookmark_url);
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM, Uri.fromFile(new File(imagePath)));
return sharingIntent;
}
If you simply want to simulate "Parsing image on the fly", delete it after sharing.
Hope this helps you!

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