How can I get the onClick event of a ShareActionProvider menu item?
My application shows some images in the gallery (fragments with imageView), and I need to get the onClick event to load the current image from the cache, create a temporary file and share it.
My sharing button:
<item android:id="@+id/menu_item_share" android:showAsAction="ifRoom" android:title="@string/menu_share" android:actionProviderClass="android.widget.ShareActionProvider" />
I tried:
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; case R.id.manage_keywords: startActivity(new Intent(this, KeywordActivity.class)); return true; case R.id.menu_item_share: return true; } return super.onOptionsItemSelected(item); }
and
menuShare = menu.findItem(R.id.menu_item_share); menuShare.setOnActionExpandListener(new OnActionExpandListener() { @Override public boolean onMenuItemActionExpand(MenuItem item) { // TODO Auto-generated method stub return false; } @Override public boolean onMenuItemActionCollapse(MenuItem item) { // TODO Auto-generated method stub return false; } });
Any other suggestion? Thanks!
source share