Skip to content

Instantly share code, notes, and snippets.

@benigumocom
Last active January 1, 2016 09:59
Show Gist options
  • Save benigumocom/8129001 to your computer and use it in GitHub Desktop.
Save benigumocom/8129001 to your computer and use it in GitHub Desktop.
/*
ShareActionProvider
android.support.v7.widget.ShareActionProvider
*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu
getMenuInflater().inflate(R.menu.main_memu, menu);
// Find the share item
MenuItem shareItem = menu.findItem(R.id.menu_share);
// Rettieve the ShareActionProvider
mShareAp = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
return super.onCreateOptionsMenu(menu);
}
//Later when you have create a share intent
mShareAp.setShareIntent(shareIntentForContent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment