Skip to content

Instantly share code, notes, and snippets.

View aegis123's full-sized avatar

Dylan Drost aegis123

View GitHub Profile
@aegis123
aegis123 / activity.java
Created May 7, 2013 13:29
create a share intent with ShareActionProvider and text/plain to share something on android
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
MenuItem actionItem = menu.findItem(R.id.menu_item_share);
ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider();
actionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
// Note that you can set/change the intent any time,
// say when the user has selected an image.
actionProvider.setShareIntent(createShareIntent());
}