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..
use this code onClick,,
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) {
Toast.makeText(context,"Please Install Facebook Messenger", Toast.LENGTH_LONG).show();
}
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
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.