I'm using ActionBarSherlock in my project, and want to set a share button to post content at FB etc etc... I achieved that this way: Adding items to action bar (using ActionBarSherlock)
As you may know, ShareActionProvider adds a second icon with the most used option for sharing. That means another app's icon is appearing in my action bar, and I want to prevent that behavior... I've seen 2 possible solutions for that, and unfortunately both didn't worked to me :/
The first attempt was, in my target class, to implement OnShareTargetSelectedListener and override onShareTargetSelected method (like here: ActionBarSherlock - Share Content icon issue). But the extra icon stays there... here is my code:
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
getSupportMenuInflater().inflate(R.menu.share, menu);
mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.share).getActionProvider();
Intent intent = getDefaultShareIntent();
mShareActionProvider.setOnShareTargetSelectedListener(this);
if(intent!=null)
mShareActionProvider.setShareIntent(intent);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onShareTargetSelected(ShareActionProvider source,
Intent intent) {
this.startActivity(intent);
// started activity ourself to prevent search history
return true;
}
The second attempt was to rewrite some classes from ActionBarSherlock, to prevent it from showing the extra icon (like here: How to hide the share action (which use most) icon near the share action provider?). But I got problems with this solution, as I couldn't import com.actionbarsherlock.widget.ActivityChooserModel from my custom classes (blocked to outer packages). Even copying this class to my package, it didn't worked (app crashes)...
Looks like its a pretty usual thing to disable this extra icon, but I couldn't figure out why the solutions above didn't worked to me...
Thanks in advance for any ideas and sugestions