Share a text with facebook messenger?

Boldijar Paul picture Boldijar Paul · Sep 29, 2014 · Viewed 25.1k times · Source

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..

Answer

Dhinakaran Thennarasu picture Dhinakaran Thennarasu · Sep 29, 2014

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