I'm setting up a share button using the onCreateOptionsMenu and ActionShareProvider.
I setup the initial intent at onCreate but I'm looking for a way the update the ShareActionProvider intent (refresh intent EXTRA) when user clicks the share icon on the activity actionBar also . Is it possible to override this onClick function?
My onCreateOptionMenu code:
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_shopping_list, menu);
MenuItem item = menu.findItem(R.id.action_share);
mShareActionProvider = new ShareActionProvider(ctx);
item.setActionProvider(mShareActionProvider);
if (mShareActionProvider != null) {
mShareActionProvider.setShareIntent(mShareIntent);
}
return super.onCreateOptionsMenu(menu);
}
Initial onCreate setup code:
mShareIntent = new Intent();
mShareIntent.setAction(Intent.ACTION_SEND);
mShareIntent.setType("text/plain");
mShareIntent.putExtra(Intent.EXTRA_TEXT, shareList());
My refresh intent code (I want to add this to the share onClick function):
mShareIntent.removeExtra(Intent.EXTRA_TEXT);
mShareIntent.putExtra(Intent.EXTRA_TEXT, shareList());
Any help appreciated.