How to add Facebook Share button in Android Application - android

I am beginner in android.I want to add FacebookShare button in my android application.I create the app in 2.2 .please help me
I use this code
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,getResources().getStri‌​ng(R.string.title_activity_android_face_book_share));
emailIntent.putExtra(android‌​.content.Intent.EXTRA_TEXT,getResources().getString(R.string.title_activity_android_face_book_share));
startActivity(emailIntent);
I Use the following link also Best way for social sharing in Android

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, "URLyouWantToShare");
startActivity(Intent.createChooser(shareIntent, "Share..."));
Use the ACTION_SEND Intent, add the URL you want to share. User will be given a selection of apps to accept the share intent such as facebook etc.

Related

How to make app picker for sharing text permanent in Android?

I'm trying to make refer and earn activity in my appSo I want to permanently display a few apps like whatsapp, etc for the user to click on them and share directly.I'm using Intent to share the referral code but it pops up the apps list when the user clicks share.The code I'm using is,
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, "This is a message");
intent.setType("text/plain");
startActivity(Intent.createChooser(intent, "Share via"));
How can I make the app chooser permanent for a few apps?
The app chooser is not intended to be displayed permanently. Therefore you will have to create simple buttons or icons and create an intent that refers to the desired app directly, by setting the package of the intent.
E.g. to share sth with WhatsApp use sth like this:
Intent sendIntent = new Intent();
// here comes the magic
sendIntent.setPackage("com.whatsapp");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send.");
sendIntent.setType("text/plain");
startActivity(sendIntent);
Depending on the type of content you want to share and the apps you want to share with, it makes sense to reuse the code to create the intent and just set the respective package and eventually some additional parameters.
You will need package name of app and a Intent.
change ACTION_VIEW to ACTION_SENDTO
set the Uri as you did set the
package to whatsapp
Intent i = new Intent(Intent.ACTION_SENDTO,
Uri.parse("content://com.android.contacts/data/" + c.getString(0)));
i.setType("text/plain");
i.setPackage("com.whatsapp"); // so that only Whatsapp reacts and not the chooser
i.putExtra(Intent.EXTRA_SUBJECT, "Subject");
i.putExtra(Intent.EXTRA_TEXT, "I'm the body.");
startActivity(i);
You can refer this link for More:
Send text to specific contact (whatsapp)
Sending message through WhatsApp
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("*/*");
intent.setPackage("com.whatsapp");
intent.putExtra(Intent.EXTRA_TEXT, "your text content");
startActivity(intent)
I am facing same problem for share tamil font content in Whatsapp. I found the solution, this setType("*/*") share full content.

Android - Chooser dialog for sharing -- different intents depending on application selected?

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)

how to share available content in textview using share option

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.

Google mobile compose page URL

I want to send a predifined google+ message via android, but I\m not sure I found the right URL for that. I found https://plus.google.com/app/plus/mp/430/#~loop:view=compose , but it's not setting my text. Is there actually another official app URL that could allow that? Twitter has the one bellow. 10x
Intent i = new Intent();
i.putExtra(Intent.EXTRA_TEXT, msg);
i.setAction(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet"));
ctx.startActivity(i);
You can share text and images on Google+ with the ACTION_SEND intent.
Example:
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_TEXT, "Hello World!");
shareIntent.setType("text/plain");
startActivity(shareIntent);
If you would like to target the Google+ app directly, you can call setPackage on the shareIntent before calling startActivity.
shareIntent.setPackage("com.google.android.apps.plus");

Android: action_send intent is not showing facebook

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.

Categories

Resources