@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { menu.setGroupVisible(R.id.main_menu_group_share, true); final ShareActionProvider shareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider(); shareActionProvider.setShareIntent(getShareIntent()); shareActionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener() { @Override public boolean onShareTargetSelected(ShareActionProvider actionProvider, Intent intent) { Analytics.getInstance().logEvent(TAG, "share",""); takeScreenShotWithCheck(); return false; } }); }