I want to take whatever page the user user is on in my WebView and allow them to share the URL with FaceBook/etc as a ACTION_SEND intent.
I tried this but obviously the URL doesn't exist in the onCreateOptionsMenu. How can I move it to the onOptionsItemsSelected?
private ShareActionProvider mShareActionProvider;
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
return super.onOptionsItemSelected(item);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
MenuItem item = menu.findItem(R.id.menu_item_share);
mShareActionProvider = (ShareActionProvider)item.getActionProvider();
mShareActionProvider.setShareHistoryFileName(
ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
mShareActionProvider.setShareIntent(createShareIntent());
return true;
}
private Intent createShareIntent() {
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT,
web.getUrl());
return shareIntent;
}