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.
Related
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)
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."
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"));
}
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.
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.