public boolean performItemAction(MenuItem item, int flags) { MenuItemImpl itemImpl = (MenuItemImpl) item; if (itemImpl == null || !itemImpl.isEnabled()) { return false; } boolean invoked = itemImpl.invoke(); // if (itemImpl.hasCollapsibleActionView()) { // invoked |= itemImpl.expandActionView(); // if (invoked) close(true); // } else if (item.hasSubMenu()) { close(false); final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); final ActionProvider provider = item.getActionProvider(); if (provider != null && provider.hasSubMenu()) { provider.onPrepareSubMenu(subMenu); } invoked |= dispatchSubMenuSelected(subMenu); if (!invoked) close(true); } else { if ((flags & FLAG_PERFORM_NO_CLOSE) == 0) { close(true); } } return invoked; }
@Override public ActionProvider getActionProvider() { android.view.ActionProvider nativeProvider = mNativeItem.getActionProvider(); if (nativeProvider != null && nativeProvider instanceof ActionProviderWrapper) { return ((ActionProviderWrapper) nativeProvider).unwrap(); } return null; }
public void createActionBarMenu(int menuRes, Menu menu) { mActivity.getMenuInflater().inflate(menuRes, menu); mActionBarMenu = menu; MenuItem item = menu.findItem(R.id.action_share_panorama); if (item != null) { mSharePanoramaActionProvider = (ShareActionProvider) item.getActionProvider(); mSharePanoramaActionProvider.setShareHistoryFileName("panorama_share_history.xml"); mSharePanoramaActionProvider.setShareIntent(mSharePanoramaIntent); } item = menu.findItem(R.id.action_share); if (item != null) { mShareActionProvider = (ShareActionProvider) item.getActionProvider(); mShareActionProvider.setShareHistoryFileName("share_history.xml"); mShareActionProvider.setShareIntent(mShareIntent); } }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_image, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); return true; }
@Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.selection_cab, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.tests_activity_actions, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); setShareIntent(); return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_player, menu); MenuItem mediaRouteMenuItem = menu.findItem(R.id.menu_media_route); if (mediaRouteMenuItem != null) { MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider) mediaRouteMenuItem.getActionProvider(); mediaRouteActionProvider.setRouteTypes(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); } return true; }
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.actionbar_menu_browserweibomsgactivity, menu); if (msg.getUser() != null && msg.getUser().getId().equals(GlobalContext.getInstance().getCurrentAccountId())) { menu.findItem(R.id.menu_delete).setVisible(true); } MenuItem item = menu.findItem(R.id.menu_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); buildShareActionMenu(); return super.onCreateOptionsMenu(menu); }
private void setShareIntent(Menu menu) { if (menu != null) { MenuItem item = menu.findItem(R.id.menu_item_share); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TITLE, mTitle); shareIntent.putExtra(Intent.EXTRA_TEXT, getSharedContent()); shareIntent.putExtra(Intent.EXTRA_ORIGINATING_URI, mUrl); shareIntent.setType("text/plain"); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); if (mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } } }
// This is the share menu public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.share_menu, menu); MenuItem item = menu.findItem(R.id.menu_item_share); mShareActionProvider = (ShareActionProvider) item.getActionProvider(); // Create the share Intent String playStoreLink = " https://play.google.com/store/apps/details?id=" + getPackageName(); String yourShareText = getString(R.string.share_this) + playStoreLink; Intent shareIntent = ShareCompat.IntentBuilder.from(this) .setType("text/plain") .setText(yourShareText) .getIntent(); // Set the share Intent mShareActionProvider.setShareIntent(shareIntent); return true; }