android.support.v7.widget.ShareActionProvider Java Examples
The following examples show how to use
android.support.v7.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: BrowserActivity.java From TLint with Apache License 2.0 | 6 votes |
@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); }
Example #2
Source File: ImageViewerActivity.java From android-imageviewer with Apache License 2.0 | 6 votes |
@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; }
Example #3
Source File: BooksPagerFragment.java From barterli_android with Apache License 2.0 | 6 votes |
@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); } }
Example #4
Source File: MainActivity.java From android-ActionBarCompat-ShareActionProvider with Apache License 2.0 | 6 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu resource getMenuInflater().inflate(R.menu.main_menu, menu); // Retrieve the share menu item MenuItem shareItem = menu.findItem(R.id.menu_share); // Now get the ShareActionProvider from the item mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareItem); // Get the ViewPager's current item position and set its ShareIntent. int currentViewPagerItem = ((ViewPager) findViewById(R.id.viewpager)).getCurrentItem(); setShareIntent(currentViewPagerItem); return super.onCreateOptionsMenu(menu); }
Example #5
Source File: DetailActivity.java From android-weather with MIT License | 6 votes |
@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; }
Example #6
Source File: FileExplorerAction.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
@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; }
Example #7
Source File: FileExplorerAction.java From 920-text-editor-v2 with Apache License 2.0 | 6 votes |
@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; }
Example #8
Source File: RideDetailActivity.java From android-ponewheel with MIT License | 6 votes |
@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; }
Example #9
Source File: DetailFragment.java From Krishi-Seva with MIT License | 6 votes |
@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()); } }
Example #10
Source File: CollectionActivity.java From Jager with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu (Menu menu) { getMenuInflater ().inflate (R.menu.collection_menu, menu); MenuItem item = menu.findItem (R.id.menu_collection_share); ShareActionProvider shareActionProvider = new ShareActionProvider (this); shareActionProvider.setShareIntent (getShareIntent ()); MenuItemCompat.setActionProvider (item, shareActionProvider); return true; }
Example #11
Source File: MsgParseActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_msg_parse, menu); MenuItem item = menu.findItem(R.id.menu_share_msgs); ShareActionProvider sp = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(mHtml)); String subject = getString(R.string.app_name) + ": " + mActivityName + ": " + mMsgName; sendIntent.putExtra(Intent.EXTRA_SUBJECT, subject); sendIntent.setType("text/html"); sp.setShareIntent(sendIntent); return true; }
Example #12
Source File: BatchSelectActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_batch_select, menu); MenuItem item = menu.findItem(R.id.menu_share_msgs); mConsole.setShareProvider((ShareActionProvider) MenuItemCompat.getActionProvider(item)); return true; }
Example #13
Source File: AppSelectActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_app_select, menu); mManualMenuItem = menu.findItem(R.id.menu_manual); prepareOptionsMenu(); MenuItem item = menu.findItem(R.id.menu_share_msgs); mConsole.setShareProvider((ShareActionProvider) MenuItemCompat.getActionProvider(item)); return true; }
Example #14
Source File: EmvReadActivity.java From smartcard-reader with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_emv_read, menu); MenuItem item = menu.findItem(R.id.menu_share_msgs); mConsole.setShareProvider((ShareActionProvider) MenuItemCompat.getActionProvider(item)); return true; }
Example #15
Source File: MainActivity.java From DexMovingImageView with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem item = menu.findItem(R.id.menu_share); ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "https://github.com/dexlex/DexMovingImageView"); sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Moving ImageView on GitHub"); sendIntent.setType("text/plain"); mShareActionProvider.setShareIntent(sendIntent); return true; }
Example #16
Source File: ImgViewer.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.image_view, menu); MenuItem item = menu.findItem(R.id.share_it); shareActionProvider = new ShareActionProvider(ImgViewer.this); MenuItemCompat.setActionProvider(item, shareActionProvider); // Fetch and store ShareActionProvider return true; }
Example #17
Source File: SubjectFragment.java From android-galaxyzoo with GNU General Public License v3.0 | 5 votes |
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { // Inflate the menu items for use in the action bar inflater.inflate(R.menu.actionbar_menu_subject, menu); // Locate MenuItem with ShareActionProvider final MenuItem item = menu.findItem(R.id.option_menu_item_share); // Fetch and store ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); updateShareActionIntent(); super.onCreateOptionsMenu(menu, inflater); }
Example #18
Source File: BookDetailFragment.java From barterli_android with Apache License 2.0 | 5 votes |
@Override public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) { if (mOwnedByUser) { inflater.inflate(R.menu.menu_logged_in_book_detail, menu); } else { inflater.inflate(R.menu.menu_book_detail, menu); } final MenuItem menuItem = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); updateShareIntent(mBookTitle); }
Example #19
Source File: CatViewerActivity.java From android-aop-analytics with Apache License 2.0 | 5 votes |
private void initShareActionProvider(Menu menu) { MenuItem shareMenuItem = menu.findItem(R.id.action_share); ShareActionProvider actionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem); Intent shareIntent = new Intent(Intent.ACTION_VIEW); shareIntent.setType(catImage.getType()); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(catImage.getLink())); actionProvider.setShareIntent(shareIntent); actionProvider.setOnShareTargetSelectedListener((source, intent) -> { trackSharingAction(analyticsTrackerHelper, AnalyticsTags.CATEGORY_ACTION, AnalyticsTags.ACTION_SHARE); return true; }); }
Example #20
Source File: ReceiptViewActivity.java From budget-watch with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.share_menu, menu); // Locate MenuItem with ShareActionProvider MenuItem item = menu.findItem(R.id.action_share); // Fetch ShareActionProvider ShareActionProvider shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); if (shareActionProvider == null) { Log.w(TAG, "Failed to find share action provider"); return false; } if(receiptFilename == null) { Log.w(TAG, "No receipt to share"); return false; } Intent shareIntent = new Intent(Intent.ACTION_SEND); // Determine mimetype of image BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; BitmapFactory.decodeFile(receiptFilename, opt); shareIntent.setType(opt.outMimeType); Uri outputUri = FileProvider.getUriForFile(this, BuildConfig.APPLICATION_ID, new File(receiptFilename)); shareIntent.putExtra(Intent.EXTRA_STREAM, outputUri); // set flag to give temporary permission to external app to use the FileProvider shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); shareActionProvider.setShareIntent(shareIntent); return super.onCreateOptionsMenu(menu); }
Example #21
Source File: CommentActivity.java From ting with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.song_menu, menu); MenuItem item = menu.findItem(R.id.action_share); shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); return true; }
Example #22
Source File: AudioNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.audio, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example #23
Source File: ChecklistNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.checklist, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example #24
Source File: SketchActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.audio, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example #25
Source File: TextNoteActivity.java From privacy-friendly-notes with GNU General Public License v3.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. if (edit){ getMenuInflater().inflate(R.menu.text, menu); MenuItem item = menu.findItem(R.id.action_share); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item); setShareIntent(); } return true; }
Example #26
Source File: DeviceDetailActivity.java From device-database with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.activity_device_detail, menu); MenuItem menuItem = menu.findItem(R.id.action_share); shareIntent = new Intent(Intent.ACTION_SEND) .setType("text/plain"); ShareActionProvider provider = (ShareActionProvider) MenuItemCompat.getActionProvider(menuItem); provider.setShareIntent(shareIntent); return true; }
Example #27
Source File: FileExplorerAction.java From java-n-IDE-for-Android with Apache License 2.0 | 4 votes |
@Override public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { destroyActionMode(); return false; }
Example #28
Source File: Console.java From smartcard-reader with GNU General Public License v3.0 | 4 votes |
public void setShareProvider(ShareActionProvider sp) { mShareProvider = sp; }
Example #29
Source File: MovieDetailFragment.java From popular-movies-app with Apache License 2.0 | 4 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.movie_detail_fragment, menu); MenuItem shareTrailerMenuItem = menu.findItem(R.id.share_trailer); mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareTrailerMenuItem); }
Example #30
Source File: FileExplorerAction.java From 920-text-editor-v2 with Apache License 2.0 | 4 votes |
@Override public boolean onShareTargetSelected(ShareActionProvider source, Intent intent) { destroyActionMode(); return false; }