I tried to use android.support.v7.widget.ShareActionProvider on actionbar in my app. So I followed the example from android document but got some issues.
Here\'s my m
You should change the declaration and definition of onCreateOptionsMenu function. you have changed the function declaration from that of the base class. this means the method is not overridden.
Try this :
@Override
public boolean onCreateOptionsMenu (Menu menu) {
inflater.inflate(R.menu.share, menu);// declare a local layout inflater
MenuItem shareItem = menu.findItem(R.id.action_share);
ShareActionProvider mShareActionProvider = (ShareActionProvider)MenuItemCompat.getActionProvider(shareItem);
mShareActionProvider.setShareIntent(getDefaultIntent());
// super.onCreateOptionsMenu(menu, inflater); <--- Remove this line or put in the first line because base class constructor should be called in the first line of the method.
return super.onCreateOptionsMenu(menu);//<-- Add this line to set the menu after adding menu items
}