0

I have a button on my app when the user finish the game, he can public in the facebook, somebody can help me? I have this code but it's for publishing the app on facebook don't know if it works either:

MenuItem item = menu.findItem(R.id.menu_item_share);
ShareActionProvider myShareActionProvider = (ShareActionProvider) item.getActionProvider();
Intent myIntent = new Intent();
myIntent.setAction(Intent.ACTION_SEND);
myIntent.putExtra(Intent.EXTRA_TEXT, "texte");
myIntent.setType("text/plain");

myShareActionProvider.setShareIntent(myIntent);
Unihedron
  • 10,902
  • 13
  • 62
  • 72

1 Answers1

1

Try this. It gives all the application list which have sharing feature available.You can also optimize it for facebook only by selecting facebook intent in createChooser().

Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, "text");

    startActivity(Intent.createChooser(intent, "Share with:"));
Ved
  • 1,035
  • 14
  • 28