@Override
 public void onResume() {
   super.onResume();
   if (mShareActionProvider != null) {
     mShareActionProvider.setOnShareTargetSelectedListener(this);
   }
 }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.filtershow_activity_menu, menu);
    MenuItem showHistory = menu.findItem(R.id.operationsButton);
    if (mShowingHistoryPanel) {
      showHistory.setTitle(R.string.hide_history_panel);
    } else {
      showHistory.setTitle(R.string.show_history_panel);
    }
    MenuItem showState = menu.findItem(R.id.showImageStateButton);
    if (mShowingImageStatePanel) {
      showState.setTitle(R.string.hide_imagestate_panel);
    } else {
      showState.setTitle(R.string.show_imagestate_panel);
    }
    mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider();
    mShareActionProvider.setShareIntent(getDefaultShareIntent());
    mShareActionProvider.setOnShareTargetSelectedListener(this);

    MenuItem undoItem = menu.findItem(R.id.undoButton);
    MenuItem redoItem = menu.findItem(R.id.redoButton);
    MenuItem resetItem = menu.findItem(R.id.resetHistoryButton);
    mImageShow.getHistory().setMenuItems(undoItem, redoItem, resetItem);
    return true;
  }
 public void setShareIntents(
     Intent sharePanoramaIntent,
     Intent shareIntent,
     ShareActionProvider.OnShareTargetSelectedListener onShareListener) {
   mSharePanoramaIntent = sharePanoramaIntent;
   if (mSharePanoramaActionProvider != null) {
     mSharePanoramaActionProvider.setShareIntent(sharePanoramaIntent);
   }
   mShareIntent = shareIntent;
   if (mShareActionProvider != null) {
     mShareActionProvider.setShareIntent(shareIntent);
     mShareActionProvider.setOnShareTargetSelectedListener(onShareListener);
   }
 }