Search code examples
androidfacebookurlshareapplinks

Facebook on Android exits immediately when sharing with it from my app


When I share some URL (as text) from my app with Facebook, the Facebook new post activity appears and exits immediately and my app re-appears. The user has no chance to submit it, or even review and finish it. This is (apparently) not a crash, there is no notification about Facebook app crashing. When shared with some other app (e.g. Gmail), it works fine.

Unfortunately this only happens on some devices. All devices where I tested it have the same version of the Facebook app. It's not related to Android version (tested on two 4.4 devices, one of them is OK and one is not).

This is what I'm doing in my app:

String textToShare = "http://lovelikeorhate.eu/question/LOVE/3";
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textToShare);
sendIntent.putExtra("com.facebook.platform.extra.APPLICATION_ID", getString(R.string.facebook_app_id));
sendIntent.setType("text/plain");
startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));

Any ideas what might be wrong? The URL is applinks enabled, could it be related?


Solution

  • The app needs to be in production mode on Facebook. This is the same problem: ClassNotFoundException on opening facebook share icon in android