there is Viewpager used in my code in which 4 Fragments. when I click on Any Fragment Item it will redirect to another fragment class in which I want Share Action to be used..
But it didn't Support..
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
// TODO Auto-generated method stub
menu.clear();
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu1, menu);
}
/* (non-Javadoc)
* @see android.support.v4.app.Fragment#onOptionsItemSelected(android.view.MenuItem)
*/
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.menu_item_share:
/* mShareActionProvider = (ShareActionProvider) item.getActionProvider();
setShareIntent(createShareIntent());
return true; */
Toast.makeText(getActivity(), "Success", 100).show();
break;
default:
break;
}
return super.onOptionsItemSelected(item);
}
I used Above code in my Fragment class..! In which I mention setHasOptionsMenu(true); in OncreatView() Methos.. // But Didn't get Solution!
Done with this Solution..
ShareActionProvider mShareActionProvider = new ShareActionProvider(getActivity());
if(mShareActionProvider != null) {
mShareActionProvider.setShareIntent(createShareIntent());
} else {
Log.d(LOG_TAG, "Share action provider is null");
}