I'm creating a small application and tried to provide a Share button on the ActionBar. The relevant code looks as below:
Manifest
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
Menu Item
<item android:id="@+id/shareMenuItem" android:showAsAction="never" android:title="@string/shareAction" android:orderInCategory="100" android:actionProviderClass="android.widget.ShareActionProvider"></item>
Activity
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
MenuItem shareItem = menu.findItem(R.id.shareMenuItem);
mShareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
return super.onCreateOptionsMenu(menu);
}
Everything works fine in this scenario. I wanted to show the Share button on the ActionBar and changed showAsAction="ifRoom". The Share button now shows up in the ActionBar, but its not clickable.
I tried to change other menu items to ifRoom, and they are working fine. Don't really understand why Share button alone is not working correctly. Any help/suggestions are appreciated!