androidx.appcompat.widget.ShareActionProvider Java Examples

The following examples show how to use androidx.appcompat.widget.ShareActionProvider. 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: LogActivity.java    From syncthing-android with Mozilla Public License 2.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.log_list, menu);

    MenuItem switchLog = menu.findItem(R.id.switch_logs);
    switchLog.setTitle(mSyncthingLog ? R.string.view_android_log : R.string.view_syncthing_log);

    // Add the share button
    MenuItem shareItem = menu.findItem(R.id.menu_share);
    ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    mShareIntent = new Intent();
    mShareIntent.setAction(Intent.ACTION_SEND);
    mShareIntent.setType("text/plain");
    mShareIntent.putExtra(android.content.Intent.EXTRA_TEXT, mLog.getText());
    actionProvider.setShareIntent(mShareIntent);

    return true;
}
 
Example #2
Source File: ViewTaskFragment.java    From opentasks with Apache License 2.0 5 votes vote down vote up
private void setSendMenuIntent()
{
    if (mContentSet != null && mModel != null && mToolBar != null && mToolBar.getMenu() != null)
    {
        MenuItem shareItem = mToolBar.getMenu().findItem(R.id.opentasks_send_task);
        if (shareItem != null)
        {
            ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
            Intent shareIntent = new ShareIntentFactory().create(mContentSet, mModel, mAppContext);
            actionProvider.setShareIntent(shareIntent);
        }
    }
}