androidfacebook-messenger

Share a text with 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..


Solution

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