Share a text with facebook messenger?

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


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();
    }

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.