I've implemented the rather out-of-box ShareActionProvider setup in a test app I'm experimenting with (using the support.v7.widget version). While it works fine, I want to run a little custom code - in this case just an internal stat counter sort of function to record how many times "share" was tapped on a particular item. (I understand from other answers there isn't a reliable way to determine the success of the share intent, let alone to where it was shared, so this seems like a last resort already.) The onOptionsItemSelected method does not seem to run in this situation.

This is the relevant part of my menu:

```
<item
    android:id="@+id/action_share"
    android:icon="@android:drawable/ic_menu_share"
    android:title="Share via"
    app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
    app:showAsAction="ifRoom" />

```

And the full onCreateOptionsMenu:

```
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    MenuItem shareItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "FOO");
    shareIntent.putExtra(Intent.EXTRA_TEXT, "FOO");

    mShareActionProvider.setShareIntent(shareIntent);

    return true;
}

```

On other actionbar items I would typically do something like this in onOptionsItemSelected, but it doesn't ever get called upon in this situation...

```
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Integer id = item.getItemId();
    Log.d("MainActivity", "id = " + id);
    Log.d("MainActivity", "shareid = " + R.id.action_share);
    Log.d("MainActivity", "Why won't this happen?");

    if (id.equals(R.id.action_share)) {
        Log.d("MainActivity", "Why won't this happen? 2");
    }

    return super.onOptionsItemSelected(item);
}

```

**Edit:** I think the conversation thus far is barking up the wrong tree, as when I click the share icon *nothing* in the above (revised) onOptionsItemSelected is logged (log level verbose), though the sharing list pops up, which seems to confirm my theory that the ShareActionProvider isn't calling this method at all.

**Edit 2:** I've now modified the onCreateMenuOptions to look exactly as it does [here](http://developer.android.com/training/sharing/shareaction.html) with the exception of using MenuItemCompat - you can see the full source of the activity [here](https://gist.github.com/anonymous/88bd10559bdb99a59595). Still, nothing is logged in onOptionsItemSelected. I further experimented in adding another item to the same menu that does nothing but log a message when selected, and that works just fine.