@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); copyPrivateRawResuorceToPubliclyAccessibleFile(); }
/** * Creates a sharing {@link Intent}. * * @return The sharing intent. */ private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri uri = Uri.fromFile(getFileStreamPath("shared.png")); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); return shareIntent; }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate your menu. getMenuInflater().inflate(R.menu.action_bar_share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar); 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()); // Set file with share history to the provider and set the share intent. MenuItem overflowItem = menu.findItem(R.id.menu_item_share_action_provider_overflow); ShareActionProvider overflowProvider = (ShareActionProvider) overflowItem.getActionProvider(); overflowProvider.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. overflowProvider.setShareIntent(createShareIntent()); return true; }
FileOutputStream outputStream = null; try { inputStream = getResources().openRawResource(R.raw.robot); outputStream = openFileOutput(SHARED_FILE_NAME, Context.MODE_WORLD_READABLE | Context.MODE_APPEND); byte[] buffer = new byte[1024];
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate your menu. getMenuInflater().inflate(R.menu.action_bar_share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar); 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()); // Set file with share history to the provider and set the share intent. MenuItem overflowItem = menu.findItem(R.id.menu_item_share_action_provider_overflow); ShareActionProvider overflowProvider = (ShareActionProvider) overflowItem.getActionProvider(); overflowProvider.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. overflowProvider.setShareIntent(createShareIntent()); return true; }
FileOutputStream outputStream = null; try { inputStream = getResources().openRawResource(R.raw.robot); outputStream = openFileOutput(SHARED_FILE_NAME, Context.MODE_WORLD_READABLE | Context.MODE_APPEND); byte[] buffer = new byte[1024];
/** * Creates a sharing {@link Intent}. * * @return The sharing intent. */ private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); Uri uri = Uri.fromFile(getFileStreamPath("shared.png")); shareIntent.putExtra(Intent.EXTRA_STREAM, uri); return shareIntent; }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); copyPrivateRawResuorceToPubliclyAccessibleFile(); }