Вы находитесь на странице: 1из 4

sign up

Stack Overflow

log in

Questions Tags Users Badges Unanswered Ask

Read this post in our app!

Share a text with facebook messenger?


android

facebook-messenger

Is there a way to share a text in facebook messenger using android and maybe facebook sdk as well?
I want to make something like the whatsapp way, choose your text and open an intent to choose the guy you want to send to... Is there a way to do this
with facebook messenger? It appears in the intent.choose dialog..but I only want to send to facebook messenger..

share

Paul
1,978 2 14 38

Asked
Sep 29 '14 at 13:58

ligi
16.5k 21 64 108

Edited
Sep 29 '14 at 14:00

Once you know the text that you want to share , you can use the shareACtion to directly share on messenger and messenger will let you decide which person to send this text to .
Kiloreux Sep 29 '14 at 14:07

improve this question

Checkout gist.github.com/gelldur/9c199654c91b13478979 You can share by Messanger Dawid Drozd May 27 '15 at 10:44
Well that is on iOS bro... Paul Dec 23 '15 at 9:34
add a comment

3 Answers

Order By

Votes

use this code onClick,,


14

com.facebook.orca is the package name for fb messenger.


Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent
.putExtra(Intent.EXTRA_TEXT,
"<---YOUR TEXT HERE--->.");
sendIntent.setType("text/plain");
sendIntent.setPackage("com.facebook.orca");
try
{
startActivity(sendIntent);
}
catch (android.content.ActivityNotFoundException ex)
{
ToastHelper.MakeShortText("Please Install Facebook Messenger");
}

EDIT:
Beginning early May 2015 Messenger no longer register itself as share intent target. Until it changes, code above won't work.

share

improve this answer


Dhina
2,109 4 12 26

Answered
Sep 29 '14 at 14:07

Edited
May 11 '15 at 0:38

Aw yea, thanks! Love ya. Paul Sep 29 '14 at 14:27

@WizKid we can do this on Android but not ios, cant we ? Why fb does not let ios to send text over Messenger ? alicanbatur Mar 10 '15 at 9:34

Beginning early May 2015 Messenger no longer register itself as share intent target. Until it changes, code above won't work. tomash May 4 '15 at 12:36

Thanks Tomash.. unfortunate.. will update the same.! Dhina May 11 '15 at 0:37
Messenger shows up in the default system sharing picker when you share text in chrome, so it must've been added back. Tyler Pfaff Apr 21 at 23:38

show 1 more comment

to start Facebook messenger with a particular user


Uri uri = Uri.parse("fb-messenger://user/"); uri = ContentUris.withAppendedId(uri,[provide user id]); Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);

it will start the messenger for user id you mention

share

improve this answer


Ninad Kambli
71 1 2

Answered
Apr 15 '15 at 13:13

Good to know! Thanks Paul Apr 15 '15 at 19:00


@Ninad Kambli dear pls explore the user id,how i will open specific user tanx Adil Jun 25 '15 at 8:05
user id is the one that you get when tou make a request to api of facebook i.e. "v1.0/me/friends" and get the id Ninad Kambli Jul 31 '15 at 4:32
this opens the messenger window but nothing is getting loaded. am i missing something? vipul mittal Aug 7 '15 at 5:38
add a comment

share

alternatively, you can use their messenger sdk (https://developers.facebook.com/docs/messenger/android) and that will pop up a screen
where you can select one or many users to send the message to. Only catch is you can't prefill the text , but you can attach rich media.

improve this answer


yrizk
46 6

Your Answer

Answered
Nov 11 '15 at 22:55

log in
or

Name

Email

By posting your answer, you agree to the privacy policy and terms of service.

Post Your Answer

meta chat tour help blog privacy policy legal contact us full site
Download the Stack Exchange Android app
2016 Stack Exchange, Inc

Вам также может понравиться