@Override public void afterTextChanged(Editable s) { shareIntent.putExtra(Intent.EXTRA_TEXT, s.toString()); share.setShareIntent(shareIntent); }
@Override public boolean onCreateOptionsMenu(Menu menu) { getSupportMenuInflater().inflate(R.menu.YOUR_MENU_XML, menu); ShareActionProvider provider = (ShareActionProvider) menu.findItem(R.id.menu_share).getActionProvider(); if (provider != null) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, YOUR_TEXT); shareIntent.setType("text/plain"); provider.setShareIntent(shareIntent); } return true; }
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.notes, menu); share= (ShareActionProvider)menu.findItem(R.id.share) .getActionProvider(); share.setShareIntent(shareIntent); super.onCreateOptionsMenu(menu, inflater); }
@Override public void run() { synchronized (this) { if (mShareActionProvider != null && intent != null) mShareActionProvider.setShareIntent(intent); } } });
@Override public void run() { synchronized (this) { if (provider != null && intent != null) provider.setShareIntent(intent); } } });
@Override public boolean onPrepareOptionsMenu(Menu menu) { ShareActionProvider actionProvider = (ShareActionProvider) actionItem.getActionProvider(); if (actionProvider != null) { actionProvider.setShareIntent(createShareIntent()); } return super.onPrepareOptionsMenu(menu); }
int pageNum; myPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { //Here I put the code I want to call/update when the page changes (i.e swipe) pageNum = myPager.getCurrentItem(); //update actionprovider & share intent after swiping ShareActionProvider mShareActionProvider = (ShareActionProvider) item.getActionProvider(); mShareActionProvider.setShareIntent(createShareIntent()); //I can also put a switch statement here, depending on which page. switch (pageNum) { case 0: //.....
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.menu_item_share); ShareActionProvider MenuSAP = (ShareActionProvider) MenuItemCompat.getActionProvider(item); MenuSAP.setShareIntent(createShareIntent()); return super.onCreateOptionsMenu(menu); }
@Override public boolean onCreateOptionsMenu (Menu menu) { inflater.inflate(R.menu.share, menu);// declare a local layout inflater MenuItem shareItem = menu.findItem(R.id.action_share); ShareActionProvider mShareActionProvider = (ShareActionProvider)MenuItemCompat.getActionProvider(shareItem); mShareActionProvider.setShareIntent(getDefaultIntent()); // super.onCreateOptionsMenu(menu, inflater); <--- Remove this line or put in the first line because base class constructor should be called in the first line of the method. return super.onCreateOptionsMenu(menu);//<-- Add this line to set the menu after adding menu items }
private void setIntent(String text) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, text); shareActionProvider.setShareIntent(intent); }
doShare(mShareActionProvider) ... private void doShare(ShareActionProvider mShareActionProvider) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT,"Selected text"); mShareActionProvider.setShareIntent(intent); }
Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("text/vcard"); intent.putExtra(Intent.EXTRA_STREAM, vcardPath); ShareActionProvider provider = new ShareActionProvider(context); provider.setShareIntent(intent);
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
@Override public void run() { Log.v(TAG, "Sharing intent is ready: action = " + intent.getAction()); mShareActionProvider.setShareIntent(intent); } });
private void buildShareActionMenu() { Intent sharingIntent = new Intent(Intent.ACTION_SEND); sharingIntent.setType("text/plain"); if (msg != null) { sharingIntent.putExtra(Intent.EXTRA_TEXT, msg.getText()); if (Utility.isIntentSafe(getActivity(), sharingIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(sharingIntent); } } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate your menu. getSupportMenuInflater().inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem item = menu.findItem(R.id.menu_item_share_action_provider_action_bar); ShareActionProvider provider = (ShareActionProvider) item.getActionProvider(); provider.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. provider.setShareIntent(createShareIntent()); return true }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate your menu. getSupportMenuInflater().inflate(R.menu.share_action_provider, menu); // Set file with share history to the provider and set the share intent. MenuItem item = menu.findItem(R.id.menu_item_share_action_provider_action_bar); ShareActionProvider provider = (ShareActionProvider) item.getActionProvider(); provider.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. provider.setShareIntent(createShareIntent()); return true }
public static void configureMenuItem(MenuItem item, Activity callingActivity, Intent intent) { ActionProvider itemProvider = item.getActionProvider(); ShareActionProvider provider = null; if (!(itemProvider instanceof ShareActionProvider)) { provider = new ShareActionProvider(callingActivity); } else { provider = (ShareActionProvider) itemProvider; } provider.setShareHistoryFileName(HISTORY_FILENAME_PREFIX + callingActivity.getClass().getName()); provider.setShareIntent(intent); item.setActionProvider(provider); } }
public static void configureMenuItem(MenuItem item, Activity callingActivity, Intent intent) { ActionProvider itemProvider = item.getActionProvider(); ShareActionProvider provider = null; if (!(itemProvider instanceof ShareActionProvider)) { provider = new ShareActionProvider(callingActivity); } else { provider = (ShareActionProvider) itemProvider; } provider.setShareHistoryFileName(HISTORY_FILENAME_PREFIX + callingActivity.getClass().getName()); provider.setShareIntent(intent); item.setActionProvider(provider); } }