How I can get onClick event of a ShareActionProvider menu item?
My application shows some images in a gallery (fragments with imageView) and I need get the onClick event to load the current image from cache, generate a temp file and share it.
My share button:
<item android:id="@+id/menu_item_share"
android:showAsAction="ifRoom"
android:title="@string/menu_share"
android:actionProviderClass="android.widget.ShareActionProvider" />
I've 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:
/*it should handle share option*/
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!