Android how to add extra text while sharing url - android

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 ?

Related

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.

Facebook share doesn't work correctly

I am trying to share a text containing a link via facebook.
My code work perfectly with the facebook messenger application. But not via Facebook app.
In Facebook app i am getting a sharing view with an empty edittext. I Don't want to integrate facebook api and give sharing authorisation. I don't want to do that. I think it can be done only via extras and intent.
My sharing code:
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle);
startActivity(Intent.createChooser(intent, "Share with"));
}
You cannot. See Android and Facebook share intent
And especially this link provided in one of the comment : http://developers.facebook.com/bugs/332619626816423
Walkaround: If you do not want to implement it using android SDK
and you want to use
private void ShareWebView(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, mTitle); // MUST contain 1 url
startActivity(Intent.createChooser(intent, "Share with"));
}
make sure that mTitle contains one LINK.
Why to do that: Although the fact that facebook doesn't work properly it grubs the first url or look like url from the mTitle and post-it as share url. It also automatically catch a subtitle and a photo from that url so the post/share is quite acceptable most of the time avoiding long code implementations!

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?

share image and text not working at all

I am working at sharing some info with an image from a resource. Here is the code I am using:
case R.id.menu_share:
//create the send intent
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
//set the type
shareIntent.setType("image/png");
//add a subject
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"CAR EXAMPLE");
//build the body of the message to be shared
String shareMessage = "An app...";
//add the message
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareMessage);
//add the img
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://com.car.pack/drawable/" + Integer.toString(R.drawable.log)));
//start the chooser for sharing
startActivity(Intent.createChooser(shareIntent,"Share"));
break;
The problem is that in my example I am trying to share a TEXT+IMAGE from a resource. So, when I share with GMAIl app works perfect, but with the others app wich appears in the intent occurs:
Whatsapp : Only send the image, the text not.
SMS: not appears the text and the image.
email app from mobile (sony ericcson Arc S): break the app
Facebook: only share the image, the text no.
Bluetooth: I don´t test yet
So I think that the problem was on the text... or I don´t know, if anyone can help me...
THANKS!!!
Use shareIntent.setType("*/*"); .
Also try changing ACTION_SEND to ACTION_SEND_MULTIPLE which specialized for delivering multiple data.
Check here for more details.

Categories

Resources