1

I have a string message that I want to share on facebook's messenger app, but I cant find a working solution to do that? Can someone help me do this? Right now I have this code and its not working:

String mimeType = "text/*";
        Uri contentUri = Uri.parse(getString(R.string.share_msg));
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setPackage("com.facebook.orca");
        intent.setType(mimeType);
        intent.putExtra(Intent.EXTRA_STREAM, contentUri);
        intent.putExtra(EXTRA_PROTOCOL_VERSION, PROTOCOL_VERSION);
        intent.putExtra(EXTRA_APP_ID, getString(R.string.share_msg));

        startActivityForResult(intent, SHARE_TO_MESSENGER_REQUEST_CODE);

When I run this code Facebook messenger crashes with this logs:

Handling exception for crash
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.facebook.orca/com.facebook.messaging.sharing.ShareLauncherActivity}: java.lang.NullPointerException

Does anyone knows is it possible to share text content to facebook messenger and how can I do that?

Darko Petkovski
  • 3,892
  • 13
  • 53
  • 117
  • I would follow the examples in the [docs](https://developers.facebook.com/docs/messenger/android) and try the sample messenger project bundled with the facebook SDK. If that didn't help, I would report this as a bug here: https://developers.facebook.com/bugs – ifaour Aug 21 '15 at 11:17
  • http://stackoverflow.com/questions/26101675/share-a-text-with-facebook-messenger/26101857#26101857. Please follow **Dhinakaran** response. That solution working on **facebook-android-sdk-4.5.0 sdk** so it will also hopefully for other recent versions. – Baha Nov 01 '15 at 11:21

0 Answers0