Android sharing to tumblr via SEND_ACTION : image and caption - android

I want to share from my app on Tumblr app an image and a text. This code do not work :
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "My Caption http://wonderful.url");
sendIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
sendIntent.setType("image/png");
sendIntent.setPackage("com.tumblr");
When I post this I can see the image but the caption is empty, I want to have the EXTRA_TEXT in the caption (which contains an URL).
Thanks

This is a limitation of the current Tumblr Android application. Unfortunately, if you want to include a caption with the image you are sharing then you will have to either use the Tumblr API directly, or use a third-party library like Jumblr.

Related

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."

android ACTION_SEND image and text

I want from my application to send to facebook and other applications an Image and some text so the user can share them. Currently I put the text and the image URI but when I choose facebook only the image is sent. In whatsApp also only the image is sent. In Google+ application both image and text are passed. Can someone show me the right direction?
Code example ( I don't have the original code here with me now, maybe I'll post it later)
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, uriToImage);
shareIntent.setType("image/png");
shareIntent.putExtra(Intent.EXTRA_TEXT , myText);
startActivity(Intent.createChooser(shareIntent, "Choose an app" ));
If I change ACTION_SEND to ACTION_SEND_MULTIPLE then it does not work at all. If I change type to "text/plain" or html then text is sent to whatsapp, google+ and Facebook messenger, but NOT in normal Facebook app ( it opens an empty share dialog).
You should use below lines
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/*");
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "My image");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(filename_toshare)));// this is for image . here filename_toshare is your file path.
sendIntent.putExtra(Intent.EXTRA_TEXT, "My Image ");// this is for text
startActivity(Intent.createChooser(sendIntent, "Email:"));
hope this helps you.

Android: Share Text & Image (URL) Via Intent

I am trying to share text with an image via an ACTION_SEND intent. The catch is that the image is represented by a URL, not a local URI. The code I currently have is:
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, text); // <- String
shareIntent.putExtra(Intent.EXTRA_STREAM, url); // <- URL object
Now I've tried a few variations on this. I've tried with setType("image/*"), I've tried parsing a Uri from the URL, I've tried passing the URL string itself, etc. Nothing so far seems to work. However, when sending to twitter I do see the text, just not the image.
Edit:
Apparently the original description was not helpful enough, so....when I launch the above intent it successfully opens a chosen application like Twitter, or Facebook, or Gmail, or Text Messaging, but an image appars in NONE of these apps. The text appears in Twitter - I can't remember if the text appears elsewhere, but my focus at this moment is on the image part anyway.
You won't be able to share on Facebook in that way because of Facebook's policy as it says in a known bug:
API does not support pre-filling the message for users
Intent sharingIntent = new Intent(Intent.ACTION_SEND_MULTIPLE);
sharingIntent.setType("image/*");
sharingIntent.setPackage("com.whatsapp");
sharingIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
sharingIntent.putExtra(Intent.EXTRA_TEXT,videoPos);
sharingIntent.putExtra(Intent.EXTRA_STREAM,getImageUri(getApplicationContext(), bitmap));

android - Share html link to facebook, twitter or email

I am trying to share an html link to either facebook, twitter or email. Here is what I have so far, but two things are going wrong.
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/html");
shareIntent.putExtra(Intent.EXTRA_TEXT, "<!DOCTYPE html><html><body>" + htmlUrl + "</body></html>");
startActivity(Intent.createChooser(shareIntent, "Share!"));
WHERE htmlUrl = "<a href=\"http://{url}/?q=" + queryString.substring(0, queryString.length() - 1) + "\" >Text to url! </a>"
First this only shows the email application in the list.
Secondly it's showing up as full text within the email and not as an HTML item.
Thank,
Dman
Your MIME type is wrong. Use this instead:
shareIntent.setType("text/plain");
If you just want to share a link and not full-blown HTML, just use the url as the Intent.EXTRA_TEXT value:
shareIntent.putExtra( Intent.EXTRA_TEXT, url );
Note that only a few apps (like GMail, Bluetooth and Dropbox) support sharing HTML. Use plain text to allow more apps to catch your Intent
You only miss a small change to your code - use Html.fromHtml to encode the string as HTML.
a more detailed example is available at this link:
http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/
This will not allow you to share on Facebook since the Facebook app dows not support ACTION_SEND with text/html but this will allow you to share HTML content using the Gmail app
Share to Facebook (using this method can only share the link)
Intent facebookIntent = new Intent(Intent.ACTION_SEND);
facebookIntent.setType("text/plain");
facebookIntent.setPackage("com.facebook.katana");
facebookIntent.putExtra(Intent.EXTRA_TEXT, shareUrl);
startActivity(facebookIntent);
Share to Email (using this method can change the email content to html format, but don't work using default email client, it works on gmail client.)
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle);
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(content of your email));
intent.setType("message/rfc822");
startActivity(Intent.createChooser(intent, "Share to Email..."));
Share to Twitter
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, your content);
intent.setType("application/twitter");
startActivity(intent);
Hope this helps.
This
shareIntent.setType("text/html");
should do for the html part. Why only the email shows up no idea, do you have other apps like facebook, twitter etc installed to handle share intents?

Android how to add extra text while sharing url

I want to add a feature in an android app to share url via email & facebook , I am using following piece of code ,
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);
shareIntent.putExtra(Intent.EXTRA_TEXT, content );
shareIntent.setType("text/plain");
startActivity(Intent.createChooser(shareIntent,"Share article"));
While sharing it via email I want content string to contain
content = someurl + ( Shared via MyApp )
whereas while sharing via Facebook I want to use
content = someurl
as Facebook refuses to recognize the url if I add anything to it .
can anyone help me with problem as how I can achieve both ?

Categories

Resources