Java Code Examples for android.view.MenuItem#getActionProvider()

The following examples show how to use android.view.MenuItem#getActionProvider() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionBarShareActionProviderActivity.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@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;
}
 
Example 2
Source File: BrowserWebFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.actionbar_menu_browserwebfragment, menu);
    MenuItem item = menu.findItem(R.id.menu_share);
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();
    refreshItem = menu.findItem(R.id.menu_refresh);
    super.onCreateOptionsMenu(menu, inflater);

    if (Utility.isWeiboAccountDomainLink(mUrl)) {
        String result = Utility.getDomainFromWeiboAccountLink(mUrl);
        Intent intent = new Intent(getActivity(), UserInfoActivity.class);
        intent.putExtra("domain", result);
        getActivity().startActivity(intent);
        getActivity().finish();

    } else if (Utility.isWeiboMid(mUrl)) {
        String mid = Utility.getMidFromUrl(mUrl);
        RedirectLinkToWeiboIdTask task = new RedirectLinkToWeiboIdTask(BrowserWebFragment.this, mUrl, mid);
        task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        mWebView.loadUrl(mUrl);
    }
}
 
Example 3
Source File: BrowserWebFragment.java    From iBeebo with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.actionbar_menu_browserwebfragment, menu);
    MenuItem item = menu.findItem(R.id.menu_share);
    mShareActionProvider = (ShareActionProvider) item.getActionProvider();
    refreshItem = menu.findItem(R.id.menu_refresh);
    super.onCreateOptionsMenu(menu, inflater);

    if (Utility.isWeiboAccountDomainLink(mUrl)) {
        String result = Utility.getDomainFromWeiboAccountLink(mUrl);
        Intent intent = new Intent(getActivity(), UserInfoActivity.class);
        intent.putExtra("domain", result);
        getActivity().startActivity(intent);
        getActivity().finish();

    } else if (Utility.isWeiboMid(mUrl)) {
        String mid = Utility.getMidFromUrl(mUrl);
        RedirectLinkToWeiboIdTask task = new RedirectLinkToWeiboIdTask(BrowserWebFragment.this, mUrl, mid);
        task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        mWebView.loadUrl(mUrl);
    }
}
 
Example 4
Source File: ResultActivity.java    From bankomatinfos with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.main_menu, menu);
	// Locate MenuItem with ShareActionProvider
	MenuItem item = menu.findItem(R.id.action_share);
	// Fetch and store ShareActionProvider
	ShareActionProvider shareActionProvider = (ShareActionProvider) item
			.getActionProvider();

	// set the log content as share content
	Intent shareIntent = new Intent();
	shareIntent.setAction(Intent.ACTION_SEND);
	shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
			getResources().getString(R.string.action_share_subject));
	shareIntent.putExtra(Intent.EXTRA_TEXT, AppController.getInstance()
			.getLog());
	shareIntent.setType("text/plain");
	shareActionProvider.setShareIntent(shareIntent);
	return true;
}
 
Example 5
Source File: PhotoViewerFragment.java    From glimmr with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (BuildConfig.DEBUG) Log.d(getLogTag(), "onCreateOptionsMenu");

    inflater.inflate(R.menu.photoviewer_menu, menu);
    mFavoriteButton = menu.findItem(R.id.menu_favorite);
    mWallpaperButton = menu.findItem(R.id.menu_set_wallpaper);

    /* The task could return before this has inflated, so make sure it's up
     * to date */
    if (mPhotoExtendedInfo != null) {
        updateFavoriteButtonIcon(mPhotoExtendedInfo.isFavorite());
    }

    /* Set file with share history to the provider and set the share
     * intent. */
    MenuItem shareActionItem = menu.findItem(R.id.menu_share);
    ShareActionProvider shareActionProvider =
            (ShareActionProvider) shareActionItem.getActionProvider();
    shareActionProvider.setShareHistoryFileName(
            ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
    shareActionProvider.setShareIntent(createShareIntent());
}
 
Example 6
Source File: MainActivity.java    From android-BasicMediaRouter with Apache License 2.0 6 votes vote down vote up
/**
 * Inflates the ActionBar or options menu. The menu file defines an item for
 * the {@link android.app.MediaRouteActionProvider}, which is registered here for all
 * live video devices using {@link android.media.MediaRouter#ROUTE_TYPE_LIVE_VIDEO}.
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    getMenuInflater().inflate(R.menu.main, menu);

    // BEGIN_INCLUDE(MediaRouteActionProvider)
    // Configure the media router action provider
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.menu_media_route);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider) mediaRouteMenuItem.getActionProvider();
    mediaRouteActionProvider.setRouteTypes(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
    // BEGIN_INCLUDE(MediaRouteActionProvider)

    return true;
}
 
Example 7
Source File: PlaybackFragment.java    From cwac-mediarouter with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.main, menu);

  if (client != null) {
    if (isPlaying) {
      menu.findItem(R.id.stop).setVisible(true);

      if (isPaused) {
        menu.findItem(R.id.play).setVisible(true);
      }
      else {
        menu.findItem(R.id.pause).setVisible(true);
      }
    }
    else {
      menu.findItem(R.id.play).setVisible(true);
    }
  }

  MenuItem item=menu.findItem(R.id.route_provider);
  MediaRouteActionProvider provider=
      (MediaRouteActionProvider)item.getActionProvider();

  provider.setRouteSelector(selector);
}
 
Example 8
Source File: MainActivity.java    From FacebookNotifications with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);
    shareAction = menu.findItem(R.id.menu_action_share);
    shareAction.setVisible(mPrefs.getBoolean(SHOW_SHARE_BUTTON, false));
    mShareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
    updateShareIntent();
    mMenu = menu;
    return super.onCreateOptionsMenu(menu);
}
 
Example 9
Source File: TweetFragment.java    From catnut with MIT License 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
	inflater.inflate(R.menu.tweet, menu);
	MenuItem share = menu.findItem(R.id.share);
	mShareActionProvider = (ShareActionProvider) share.getActionProvider();
	mShareActionProvider.setShareIntent(mShareIntent);
}
 
Example 10
Source File: Samples.java    From Android-Next with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    MenuItem share = menu.findItem(R.id.menu_share);
    mShareActionProvider = (AdvancedShareActionProvider) share.getActionProvider();
    updateShareIntent();
    return true;
}
 
Example 11
Source File: MainActivity.java    From cwac-mediarouter with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  getMenuInflater().inflate(R.menu.main, menu);

  MenuItem item=menu.findItem(R.id.route_provider);
  MediaRouteActionProvider provider=
      (MediaRouteActionProvider)item.getActionProvider();

  provider.setRouteSelector(selector);

  return(true);
}
 
Example 12
Source File: DataChangeLogsActivity.java    From commcare-android with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void setUpShareActionProvider(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_share, menu);
    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (CommCareShareActionProvider)item.getActionProvider();
    setShareIntent();
}
 
Example 13
Source File: MainActivity.java    From HeadFirstAndroid with MIT License 5 votes vote down vote up
@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_main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
    setIntent("This is example text");
    return super.onCreateOptionsMenu(menu);
}
 
Example 14
Source File: MainActivity.java    From HeadFirstAndroid with MIT License 5 votes vote down vote up
@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_main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
    setIntent("This is example text");
    return super.onCreateOptionsMenu(menu);
}
 
Example 15
Source File: PizzaDetailActivity.java    From HeadFirstAndroid with MIT License 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);

    //Share the name of the pizza
    TextView textView = (TextView)findViewById(R.id.pizza_text);
    CharSequence pizzaName = textView.getText();
    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_TEXT, pizzaName);
    shareActionProvider.setShareIntent(intent);
    return true;
}
 
Example 16
Source File: MainActivity.java    From HeadFirstAndroid with MIT License 5 votes vote down vote up
@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_main, menu);
    MenuItem menuItem = menu.findItem(R.id.action_share);
    shareActionProvider = (ShareActionProvider) menuItem.getActionProvider();
    setIntent("This is example text");
    return super.onCreateOptionsMenu(menu);
}
 
Example 17
Source File: FolderFragment.java    From filemanager with MIT License 5 votes vote down vote up
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu)
{
	setActionbarVisibility(true);
	getActivity().getMenuInflater().inflate(R.menu.action_file, menu);
	getActivity().getMenuInflater().inflate(R.menu.action_file_single, menu);

	MenuItem shareMenuItem = menu.findItem(R.id.action_share);
	shareActionProvider = (ShareActionProvider) shareMenuItem.getActionProvider();
	this.preserveSelection = false;
	return true;
}
 
Example 18
Source File: MainActivity.java    From OpenXiaomiScale with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
	getMenuInflater().inflate(R.menu.menu_main, menu);

	// Locate MenuItem with ShareActionProvider
	MenuItem item = menu.findItem(R.id.menu_item_share);

	// Fetch and store ShareActionProvider
	mShareActionProvider = (ShareActionProvider) item.getActionProvider();

	return true;
}
 
Example 19
Source File: VideoDetailActivity.java    From android-viewer-for-khan-academy with GNU General Public License v3.0 4 votes vote down vote up
private void prepareShareActionItem(MenuItem shareItem) {
	shareActionProvider = (ShareActionProvider) shareItem.getActionProvider();
	shareActionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME);
	shareActionProvider.setOnShareTargetSelectedListener(shareTargetSelectedListener);
	shareActionProvider.setShareIntent(prepareShareIntent(video));
}