I want a share icon in the action bar, upon pressing, a chooser shows up. I have most of this in place, but this unwelcome middle-man steps in...
The menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_share"
android:title="@string/share"
android:showAsAction="always"
android:actionProviderClass="com.actionbarsherlock.widget.ShareActionProvider"
/>
</menu>
The SherlockFragment's onCreateOptionsMenu:
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// Inflate menu resource file.
inflater.inflate(R.menu.share_menu, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.menu_share);
// Fetch and store ShareActionProvider
this.shareActionProvider = (ShareActionProvider) item.getActionProvider();
final String title = r.getString(R.string.feedback_share);
final String subject = r.getString(R.string.share_subject);
final String message = r.getString(R.string.share_message_plain);
Intent intent = app.newShareIntent(title, subject, message);
this.shareActionProvider.setShareIntent(intent);
}
The intent factory:
public Intent newShareIntent(String title, String subject, String message) {
Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/plain");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
intent.putExtra(Intent.EXTRA_SUBJECT, subject);
intent.putExtra(Intent.EXTRA_TEXT, message);
Intent chooser = Intent.createChooser(intent, title);
chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
return chooser;
}
The unwelcome middle-man:
And when I click on this guy, he does as directed and presents the chooser. But I'm really not interested in engaging his services.
What I'm after:
Or this with all three (or however many on users devices) in the drop down... or be able to set the default that appears inline with the share icon: