Java 类android.support.v7.widget.ShareActionProvider 实例源码

项目:LaravelNewsApp    文件:PostActivity.java   
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();


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

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        startActivity(new Intent(App.getAppContext(),Settings.class));
        return true;
    }else  if (id == R.id.action_favorite) {
       favourite(post);
    }else  if (id == R.id.action_share) {
        shareTextUrl();
    }
    return super.onOptionsItemSelected(item);
}
项目:Fahrplan    文件:ConnectionActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.share, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    Intent send = new Intent();
    send.setAction(Intent.ACTION_SEND);
    send.putExtra(Intent.EXTRA_TEXT, text.toString());
    send.setType("text/plain");
    if(shareAction != null) {
        shareAction.setShareIntent(send);
    }

    return super.onCreateOptionsMenu(menu);
}
项目:android-ponewheel    文件:RideDetailActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.ride_menu, menu);

    // store action provider
    shareMenuItem = menu.findItem(R.id.menu_item_share);
    shareMenuItem.setVisible(false);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);

    // Create share intent
    shareFileIntent = new Intent();
    shareFileIntent.setAction(Intent.ACTION_SEND);
    shareFileIntent.setType("text/csv");
    shareFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    setShareIntent(shareFileIntent);

    return true;
}
项目:Sprog-App    文件:PoemActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.poem_toolbar, menu);

    favoriteItem = menu.findItem(R.id.action_addToFavorites);
    if (presenter.isFavorite()){
        favoriteItem.setIcon(R.drawable.ic_star_full);
    }

    MenuItem item = menu.findItem(R.id.action_share);

    ShareActionProvider mShareActionProvider =
            (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, presenter.getPoemContentString());
    mShareActionProvider.setShareIntent(shareIntent);
    return true;
}
项目:BuddyBook    文件:DetailActivityFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    super.onCreateOptionsMenu(menu, inflater);
    if (getActivity() instanceof MainActivity) {

        ((MainActivity) getActivity()).setIntentShareMenu(createShareBookIntent(mBookSelected));

    } else {

        inflater.inflate(R.menu.menu_detail, menu);
        MenuItem menushareItem = menu.findItem(R.id.action_share);
        ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menushareItem);
        if (mBookSelected != null) {
            menushareItem.setVisible(true);
            mShareActionProvider.setShareIntent(createShareBookIntent(mBookSelected));
        }
    }
}
项目:javaide    文件:FileExplorerAction.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
    pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    pasteMenu.setEnabled(fileClipboard.canPaste());

    renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
    renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    shareMenu = menu.add(0, R.id.share, 0, R.string.share);
    shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    shareActionProvider = new ShareActionProvider(context);
    shareActionProvider.setOnShareTargetSelectedListener(this);
    MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);

    menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}
项目:getting-ready-for-android-n    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mForecast != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}
项目:Sprog-App    文件:PoemActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.poem_toolbar, menu);

    favoriteItem = menu.findItem(R.id.action_addToFavorites);
    if (presenter.isFavorite()){
        favoriteItem.setIcon(R.drawable.ic_star_full);
    }

    MenuItem item = menu.findItem(R.id.action_share);

    ShareActionProvider mShareActionProvider =
            (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, presenter.getPoemContentString());
    mShareActionProvider.setShareIntent(shareIntent);
    return true;
}
项目:ufrgs-mobile-android    文件:NewsOpenActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.news_activity_menu, menu);

    MenuItem item = menu.findItem(R.id.action_share);

    ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
       shareActionProvider.setShareIntent(getDefaultShareIntent());
    shareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
        @Override
        public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
            String shareTarget = intent.getComponent().getPackageName();
            TrackerUtils.shareNewsArticle(mNewsVo.title,shareTarget);

            return false;
        }
    });

    return super.onCreateOptionsMenu(menu);
}
项目:Weather4U    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_detail_fragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mForecast != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}
项目:Sunshine-v2    文件:DetailActivityFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.menu_detail_fragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    ShareActionProvider mShareActionProvider =
            (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // Attach an intent to this ShareActionProvider.  You can update this at any time,
    // like when the user selects a new piece of data they might like to share.
    if (mShareActionProvider != null ) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    } else {
        Log.d(LOG_TAG, "Share Action Provider is null?");
    }
}
项目:prayer-times-android    文件:HadithFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MaterialMenuInflater.with(getActivity(), inflater)
            .setDefaultColor(0xFFFFFFFF)
            .inflate(R.menu.hadis, menu);

    mSwitch = menu.findItem(R.id.favswitch);
    mFav = menu.findItem(R.id.fav);
    setCurrentPage(mPager.getCurrentItem());

    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    item = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) item.getActionView();

    searchView.setOnQueryTextListener(this);
}
项目:flavordex    文件:ViewInfoFragment.java   
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);

    final Context context = getContext();
    if(context == null || mTitle == null) {
        return;
    }

    final MenuItem shareItem = menu.findItem(R.id.menu_share);
    if(shareItem != null) {
        final Intent shareIntent = EntryUtils.getShareIntent(context, mTitle, mRating);
        final ShareActionProvider actionProvider =
                (ShareActionProvider)MenuItemCompat.getActionProvider(shareItem);
        if(actionProvider != null) {
            actionProvider.setShareIntent(shareIntent);
        }
    }
}
项目:Sunshine    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mForecast != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}
项目:920-text-editor-v2    文件:FileExplorerAction.java   
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
    menu.add(0, R.id.select_all, 0, R.string.select_all).setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
    menu.add(0, R.id.cut, 0, R.string.cut).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    menu.add(0, R.id.copy, 0, R.string.copy).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    MenuItem pasteMenu = menu.add(0, R.id.paste, 0, R.string.paste);
    pasteMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    pasteMenu.setEnabled(fileClipboard.canPaste());

    renameMenu = menu.add(0, R.id.rename, 0, R.string.rename);
    renameMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    shareMenu = menu.add(0, R.id.share, 0, R.string.share);
    shareMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    shareActionProvider = new ShareActionProvider(context);
    shareActionProvider.setOnShareTargetSelectedListener(this);
    MenuItemCompat.setActionProvider(shareMenu, shareActionProvider);

    menu.add(0, R.id.delete, 0, R.string.delete).setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    copyPathMenu = menu.add(0, R.id.copy_path, 0, R.string.copy_path);
    copyPathMenu.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    return true;
}
项目:quizmaster-android    文件:MainActivity.java   
@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 shareItem = menu.findItem(R.id.shareQuiz);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    mShareActionProvider.setShareIntent(getDefaultIntent());
    mShareActionProvider.setOnShareTargetSelectedListener(new ShareActionProvider.OnShareTargetSelectedListener() {
        @Override
        public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) {
            //     startActivity(intent);
            return false;
        }
    });
    return true;
}
项目:hci-debugger    文件:DescriptionActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    this.getMenuInflater().inflate(R.menu.toolbar_menu, menu);

    menu.findItem(R.id.packet_number_entry).setVisible(false);
    menu.findItem(R.id.clear_btn).setVisible(false);
    menu.findItem(R.id.scan_btn).setVisible(false);
    menu.findItem(R.id.state_bt_btn).setVisible(false);
    menu.findItem(R.id.reset_snoop_file).setVisible(false);
    menu.findItem(R.id.filter_btn).setVisible(false);
    menu.findItem(R.id.refresh).setVisible(false);

    MenuItem item = menu.findItem(R.id.share);

    if (item != null) {
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        setSharedIntent();
    }

    return super.onCreateOptionsMenu(menu);
}
项目:android-giftwise    文件:ContactActivity.java   
@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_contact, menu);

    // Retrieve the share menu item
    MenuItem shareItem = menu.findItem(R.id.action_share);

    // get the ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

    // create a default intent for the share action
    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(createShareIntent(""));
    } else {
        Log.d(LOG_TAG, "Problem finding ShareActionProvider");
        //shareActionProvider = new ShareActionProvider(getActivity());
        //MenuItemCompat.setActionProvider(shareItem, shareActionProvider);
    }

    return true;
}
项目:klingon-assistant    文件:EntryActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  super.onCreateOptionsMenu(menu);
  mShareButton = menu.findItem(R.id.action_share);
  mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(mShareButton);

  // This is also updated in onPageSelected.
  if (mShareActionProvider != null && mShareEntryIntent != null) {
    // Enable "Share" button.
    mShareActionProvider.setShareIntent(mShareEntryIntent);
    mShareButton.setVisible(true);
  }

  // TTS:
  // The button is disabled in the layout. It should only be enabled in EntryActivity.
  mSpeakButton = menu.findItem(R.id.action_speak);
  // if (ttsInitialized) {
  //   // Log.d(TAG, "enabling TTS button in onCreateOptionsMenu");
  mSpeakButton.setVisible(true);
  // }

  return true;
}
项目:android-weather-app    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mForecast != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}
项目:openfoodfacts-androidapp    文件:ProductActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_product, menu);
    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    String url = " " + getString(R.string.website_product) + mState.getProduct().getCode();
    if (mState.getProduct().getUrl() != null) {
        url = " " + mState.getProduct().getUrl();
    }
    shareIntent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.msg_share) + url);
    shareIntent.setType("text/plain");
    setShareIntent(shareIntent);

    return true;
}
项目:v2ex-android    文件:TopicFragment.java   
private void setupShareActionMenu(Menu menu) {
    final MenuItem itemShare = menu.findItem(R.id.action_share);

    final Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT,
            String.format("%s\n%s", mTopic.getTitle(), mTopic.getUrl()));

    if (MiscUtils.HAS_L) {
        itemShare.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
            @Override
            public boolean onMenuItemClick(MenuItem item) {
                TopicFragment.this.startActivity(Intent.createChooser(shareIntent, null));
                return true;
            }
        });
    } else {
        final ShareActionProvider actionProvider = new ShareActionProvider(getContext());
        MenuItemCompat.setActionProvider(itemShare, actionProvider);
        actionProvider.setShareIntent(shareIntent);
    }
}
项目:mysunshine    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    if (D) { Log.v(TAG, "onCreateOptionsMenu: menu: " + menu + " inflater: " + inflater); }
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detail_fragment, menu);

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

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

    if (mForecastStr != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    } else {
        if (D) { Log.d(TAG, "Share Action Provider is null?"); }
    }
}
项目:prayer-times-android    文件:HadithFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    MaterialMenuInflater.with(getActivity(), inflater)
            .setDefaultColor(0xFFFFFFFF)
            .inflate(R.menu.hadis, menu);

    mSwitch = menu.findItem(R.id.favswitch);
    mFav = menu.findItem(R.id.fav);
    setCurrentPage(mPager.getCurrentItem());

    MenuItem item = menu.findItem(R.id.menu_item_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    item = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) item.getActionView();

    searchView.setOnQueryTextListener(this);
}
项目:spst    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mForecast != null) {
        mShareActionProvider.setShareIntent(createShareForecastIntent());
    }
}
项目:TLint    文件:BrowserActivity.java   
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    menu.removeGroup(R.id.browser);
    getMenuInflater().inflate(R.menu.menu_browser, menu);

    String shareContent = String.format("%s %s ", getTitle() + "", url + "");
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, shareContent);

    MenuItem shareItem = menu.findItem(R.id.share);
    ShareActionProvider shareProvider =
            (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    shareProvider.setShareHistoryFileName("channe_share.xml");
    shareProvider.setShareIntent(shareIntent);

    return super.onPrepareOptionsMenu(menu);
}
项目:BookCommander    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu.
    // Adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // Access the Share Item defined in menu XML
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);

    // Access the object responsible for
    // putting together the sharing submenu
    if (shareItem != null) {
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    }

    // Create an Intent to share your content
    setShareIntent();
    return true;
}
项目:BookCommander    文件:DetailActivity.java   
@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);

    // Access the Share Item defined in menu XML
    MenuItem shareItem = menu.findItem(R.id.menu_item_share);

    // Access the object responsible for
    // putting together the sharing submenu
    if (shareItem != null) {
        mShareActionProvider
                = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);
    }

    setShareIntent();

    return true;
}
项目:android-movies    文件:MainActivity.java   
/**
 * Overridden method to display the share action button in the options menu
 *
 * @param menu the options menu
 * @return boolean - if options were created for the menu
 */
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    if (mTwoPane) {
        getMenuInflater().inflate(R.menu.menu_main, menu);

        // Locate MenuItem with ShareActionProvider
        MenuItem shareItem = menu.findItem(R.id.menu_item_share);
        // Fetch and store ShareActionProvider
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem);

        if (mShareActionProvider != null) {
            mShareActionProvider.setShareIntent(getDefaultShareIntent());
        } else {
            Log.d(LOG_TAG, "ShareActionProvider is null");
            return false;
        }
    }
    return true;
}
项目:android-weather    文件:DetailActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.detail, menu);

    // Locate MenuItem with ShareActionProvider
    MenuItem item = menu.findItem(R.id.menu_item_share);
    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(getDefaultShareIntent());
    }
    else {
        Log.d(LOG_TAG, "ShareActionProvider is null");
    }
    return true;
}
项目:android-SimpleNetCat    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu( Menu menu )
{
    getMenuInflater().inflate( R.menu.actions, menu );
    this.menu = menu;
    cancelItem = menu.findItem( R.id.action_cancel );
    clearItem = menu.findItem( R.id.action_clear );
    shareItem = menu.findItem( R.id.action_share );
    shareProvider = (ShareActionProvider) MenuItemCompat.getActionProvider( shareItem );
    statusItem = menu.findItem( R.id.action_state );
    stateView = (TextView) MenuItemCompat.getActionView( statusItem );
    if( actionsVisibility != null ) {
        setActionsVisibility( actionsVisibility );
    }
    if( netCatState != null ) {
        stateView.setText( netCatState.toString() );
    }
    return super.onCreateOptionsMenu( menu );
}
项目:KnightNews_Android    文件:ReaderFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.feed, menu);
    // Set up ShareActionProvider's default share intent
    MenuItem shareItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat
            .getActionProvider(shareItem);

    if (mShareActionProvider != null) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, mStory.getTitle());
        intent.putExtra(Intent.EXTRA_TEXT, mStory.getDescription() + "\n"
                + mStory.getUrl() + "\n\n\n" + "Via KnightNews for Android");

        mShareActionProvider.setShareIntent(intent);
    }

    super.onCreateOptionsMenu(menu, inflater);
}
项目:ShutUpAndDrive    文件:MainActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    if (Utils.DEVELOPER)
        menu.add(getString(R.string.tutorial));
    MenuItem item = menu.findItem(R.id.action_share);
    ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_TEXT, "I’ve driven without distractions for " +
            (int) Math.round(Utils.millisToHours(UserSettings.getTotalTime(this)))
            + " hours!\n\n" + PREVENT + PLAY_STORE_LINK);
    if (mShareActionProvider != null) {
        mShareActionProvider.setShareIntent(i);
    }
    return true;
}
项目:XDA-One    文件:ThreadActionModeHelper.java   
@Override
public boolean onCreateActionMode(final ActionMode actionMode, final Menu menu) {
    final BaseActivity baseActivity = UIUtils.getBaseActivity(mActivity);
    baseActivity.getMenuInflater().inflate(R.menu.thread_fragment_cab, menu);

    final MenuItem shareMenuItem = menu.findItem(R.id.thread_fragment_cab_share);

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

    // Get the subscribed menu item
    mSubscribeItem = menu.findItem(R.id.thread_fragment_cab_subscribe);

    return true;
}
项目:XDA-One    文件:ForumFragment.java   
@Override
public boolean onCreateActionMode(final ActionMode actionMode, final Menu menu) {
    final BaseActivity baseActivity = UIUtils.getBaseActivity(getActivity());
    baseActivity.getMenuInflater().inflate(R.menu.thread_fragment_cab, menu);

    // Locate MenuItem with ShareActionProvider
    mShareMenuItem = menu.findItem(R.id.forum_fragment_cab_share);

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

    // Get the subscribed menu item
    mSubscribeItem = menu.findItem(R.id.forum_fragment_cab_subscribe);

    return true;
}
项目:TiqaViewer    文件:PhotoViewFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);

    MenuItem item = menu.findItem(R.id.action_share);
    if (item != null) {
        mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
        mShareActionProvider.setOnShareTargetSelectedListener(this);

        // dummy File
        File file = createFileObj(false);
        if(file ==null) return;

        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.setType("image/jpg");

        Uri uri = Uri.fromFile(file);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
        setShareIntent(shareIntent);
    }
}
项目:syncthing-android    文件:LogActivity.java   
@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;
}
项目:barterli_android    文件:BooksPagerFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    inflater.inflate(R.menu.menu_book_detail, menu);

    final MenuItem menuItem = menu.findItem(R.id.action_share);
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    if (mAdapter.getCount() > 0) {
        final int position = mBookDetailPager.getCurrentItem();
        updateShareIntent(mAdapter.getBookTitleForPosition(position));
        updateUserProfile(position);
    } else {
        updateShareIntent(null);
    }
}
项目:android-imageviewer    文件:ImageViewerActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    // Locate MenuItem with ShareActionProvider
    MenuItem itemShare = menu.findItem(R.id.action_share);
    // Get the provider and hold onto it to set/change the share intent.
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(itemShare);
    // Set history different from the default before getting the action
    // view since a call to MenuItemCompat.getActionView() calls
    // onCreateActionView() which uses the backing file name. Omit this
    // line if using the default share history file is desired.
    shareActionProvider.setShareHistoryFileName("snowdream_android_imageviewer_share_history.xml");
    Intent shareIntent = createShareIntent();
    if (shareIntent != null) {
        doShare(shareIntent);
    }
    return true;
}
项目:WsprNetViewer    文件:DetailFragment.java   
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    // Inflate the menu; this adds items to the action bar if it is present.
    inflater.inflate(R.menu.detailfragment, menu);

    // Retrieve the share menu item
    MenuItem menuItem = menu.findItem(R.id.action_share);

    // Get the provider and hold onto it to set/change the share intent.
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem);

    // If onLoadFinished happens before this, we can go ahead and set the share intent now.
    if (mWspr != null) {
        mShareActionProvider.setShareIntent(createShareWsprIntent());
    }
}