Share an image with a text before and after - android

I want to be able to share a content from my Android app, like this template :
This is some text (mainly a description about the image shared)
The Image
Shared via MyApp
I currently use this code snippet :
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/*");
Uri imageUri = Uri.parse("android.resource://" + path);
share.putExtra(Intent.EXTRA_TEXT, "A description about the image below");
share.putExtra(Intent.EXTRA_STREAM,imageUri);
share.putExtra(Intent.EXTRA_TEXT, "Shared via MyApp");
startActivity(Intent.createChooser(share, "Choose a share option"));
Only the second putExtra is added to the share.
How can I do this task ?
Thank's a lot.
Edit : My question is different from How to Share Image + Text together using ACTION_SEND in android?
I know how to share a text and an image together, but i want to add a text before, and another text after the image.

Related

Sharing an HTML link with an image

I know how to share normal text with an image but I want to share an html link with the image. If the user will share it and the second user will click on the link it will open a particular activity on the app.
What I've tried so far
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
String textToShare = "Check out " + service_provider.businessName + "";
share.putExtra(Intent.EXTRA_TEXT, textToShare);
share.putExtra(Intent.EXTRA_STREAM,
Uri.parse("file:///sdcard/temporary_file.jpg"));
startActivity(Intent.createChooser(share, "Share Image"));
This just sends the text as a normal plain text.

Is It possible to send an image and a text file, both using a single Intent in android?

The question is (might be a repeated one), but I could not find a proper answer to it, so asking here again.
In my application, I need to share both an image and a text file using a single intent.
I read a few answers, like:
ACTION_SEND sending both an Image and Text in the same Intent,
Send Image and Text both using ACTION_SEND or ACTION_SEND_MULTIPLE
and also Problems sharing combined text and image with SHARE INTENT
and tried to implement the given solutions in my application, but none of them worked for me.
The code I've implemented so far is as below :
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_SUBJECT, "I found movie "+movieTitle+" on Movies Tracker!");
share.putExtra(Intent.EXTRA_TEXT, "my text");
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
share.setType("image/*");
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(share, "Share via"));
So now my question is: is there any way to share both an image and a text file with single intent?
If it's possible, then please help regarding this issue.
Thanks in advance.
try this one
private void initShareIntent(String type,String _text){
File filePath = getFileStreamPath("<span class="skimlinks-unlinked">shareimage.jpg</span>"); //optional //internal storage
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, _text);
shareIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(new File(filePath))); //optional//use this when you want to send an image
shareIntent.setType("image/jpeg");
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(shareIntent, "send"));
}

Android sharing to tumblr via SEND_ACTION : image and caption

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.

Instagram from Android open on certain user and add caption to uploaded image

Instagram for Android is very limited, from what I have seen so far. My scenario is simple: allow the user to edit a picture and when he clicks on Send:
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("image/jpeg");
Then with queryIntentActivities() I search to see if Instagram is installed. If it is I send the path of my image to be uploaded:
share.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///" + path to myfile.png"));
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
share.putExtra(Intent.EXTRA_SUBJECT, "Sample subject");
share.putExtra(Intent.EXTRA_TEXT, "Sample text");
share.putExtra(Intent.EXTRA_TITLE, "Sample title");
The result: the image is uploaded using Instagram app (of course if I am logged in), but I can't add a Caption to it. None of the putExtra has any effect. So, is there any way to add a caption as intent parameter ?
And the other question, is it possible to open Instagram app with a certain user name filled in ?
It looks as if Instagram's Android App ignores EXTRA_TEXT, EXTRA_SUBJECT and EXTRA_TITLE, so it seems that adding a caption while uploading an image is not possible. By the way, you can try different approaches to check if it ignores those extras in every case:
OPTION #1: Changing the MIME type.
You are setting the MIME type to "image/jpeg". Try using "image/" or "/*" to check if their app doesn't ignore those extras.
share.setType("image/*");
or
share.setType("*/*");
OPTION #2:
As you are sending multiple MIME types (image and text), maybe their app is expecting ACTION_SEND_MULTIPLE instead of ACTION_SEND.
Intent share = new Intent(Intent.ACTION_SEND_MULTIPLE);
OPTION #3: Use MediaStore.Images.Media.insertImage(ContentResolver cr, String imagePath, String name, String description) function:
Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), "file:///" + path to myfile.png", "Sample title", "Sample description")));
share.setType("image/jpeg");
share.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name);
OPTION #4: Post your issue in their developer forum, although there are similar questions that remain unsolved:
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption$20action_send/instagram-api-developers/PJDuG2sTDlM/6bno5dZmoTEJ
https://groups.google.com/forum/?fromgroups#!searchin/instagram-api-developers/caption/instagram-api-developers/7XUKm9HSAdg/rJbdSnOmXacJ
And don't forget to come back and tell us their answer!
It looks like Instagram has updated their app to accept EXTRA_TEXT to add a caption. If the user has an updated version of Instagram (July 1, 2014 version or later) you can post an image and add a caption with the following code:
Intent instagram = new Intent(android.content.Intent.ACTION_SEND);
instagram.setType("image/*");
instagram.putExtra(Intent.EXTRA_STREAM, [URI of photo]);
instagram.putExtra(Intent.EXTRA_TEXT, [Text of caption]);
instagram.setPackage(instagramPackageName);
startActivity(instagram);
Users with older versions will still get the image, but not have the caption be pre populated.
This code is assuming you have already been through the auth flow.

Problems sharing combined text and image with SHARE INTENT on Twitter

I want to give the user the possibility to share a Image and a Text with Twitter and Facebook.
Actually my code can launch Android's share intent and if the user selects Facebook, all works fine, the Image is attached and the text is shown on the body of the new status.
But something is wrong with Twitter, if i only put a Image all works fine, the image is detected by twitter and automatically uploaded to twipic, then twitter posts the link of the image on the tweet. But if i put a image and a text, then, twitter doesn't detect the image and it only puts the text on the tweet, the image is ignored. What is wrong?
this is my code:
Intent sharingIntent = new Intent(Intent.ACTION_SEND);
Uri screenshotUri = Uri.parse("file:///sdcard/image.jpg");
sharingIntent.setType("image/*");
sharingIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
sharingIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
startActivity(Intent.createChooser(sharingIntent, "Share image using"));
You can still try with ACTION_SEND, without using the ACTION_SEND_MULTIPLE.
ACTION_SEND_MULTIPLE resulted in a force close, when I tried to create new intents for sharing to Gmail, G+, etc.
This worked perfect for me:
Intent shareIntent = new Intent(Intent.ACTION_SEND);
Uri uri = Uri.parse("file:///sdcard/image.jpg");
shareIntent.setType("*/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "Body text of the new status");
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
return shareIntent;
Specify MIME type also for the text. "text/plain" is the type of text data MIME. Try using "*/*" as MIME, so you can send any generic data type.
Also try changing ACTION_SEND to ACTION_SEND_MULTIPLE which specialized for delivering multiple data.
More info about ACTION_SEND_MULTPLE and handling MIME types:
http://developer.android.com/reference/android/content/Intent.html

Categories

Resources