Java Code Examples for android.widget.ShareActionProvider#setShareIntent()
The following examples show how to use
android.widget.ShareActionProvider#setShareIntent() .
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: ResultActivity.java From bankomatinfos with GNU General Public License v3.0 | 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.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 2
Source File: PhotoViewerFragment.java From glimmr with Apache License 2.0 | 6 votes |
@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 3
Source File: ActionBarShareActionProviderActivity.java From codeexamples-android with Eclipse Public License 1.0 | 6 votes |
@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 4
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
Example 5
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, MessageBean msg) { Intent shareIntent = new Intent(Intent.ACTION_SEND); if (msg != null && msg.getUser() != null) { shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "@" + msg.getUser().getScreen_name() + ":" + msg.getText()); if (!TextUtils.isEmpty(msg.getThumbnail_pic())) { Uri picUrl = null; String smallPath = FileManager.getFilePathFromUrl(msg.getThumbnail_pic(), FileLocationMethod.picture_thumbnail); String middlePath = FileManager.getFilePathFromUrl(msg.getBmiddle_pic(), FileLocationMethod.picture_bmiddle); String largePath = FileManager.getFilePathFromUrl(msg.getOriginal_pic(), FileLocationMethod.picture_large); if (ImageUtility.isThisBitmapCanRead(largePath)) { picUrl = Uri.fromFile(new File(largePath)); } else if (ImageUtility.isThisBitmapCanRead(middlePath)) { picUrl = Uri.fromFile(new File(middlePath)); } else if (ImageUtility.isThisBitmapCanRead(smallPath)) { picUrl = Uri.fromFile(new File(smallPath)); } if (picUrl != null) { shareIntent.putExtra(Intent.EXTRA_STREAM, picUrl); shareIntent.setType("image/*"); } } if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } } }
Example 6
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
Example 7
Source File: PizzaDetailActivity.java From HeadFirstAndroid with MIT License | 5 votes |
@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 8
Source File: TweetFragment.java From catnut with MIT License | 5 votes |
@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 9
Source File: PhotoViewerFragment.java From catnut with MIT License | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { mShare = menu.add(Menu.NONE, R.id.action_share, Menu.NONE, R.string.share); mShare.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); mShareActionProvider = new ShareActionProvider(getActivity()); mShareActionProvider.setShareIntent(mIntent); mShare.setActionProvider(mShareActionProvider); }
Example 10
Source File: FantasyFragment.java From catnut with MIT License | 5 votes |
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.fantasy, menu); mShare = menu.findItem(R.id.action_share); if (!Intent.ACTION_MAIN.equals( getActivity().getIntent().getAction())) { menu.findItem(R.id.home).setVisible(false); } mShareActionProvider = (ShareActionProvider) mShare.getActionProvider(); mShare.setActionProvider(mShareActionProvider); mShareActionProvider.setShareIntent(mIntent); }
Example 11
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
Example 12
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, MessageBean msg) { Intent shareIntent = new Intent(Intent.ACTION_SEND); if (msg != null && msg.getUser() != null) { shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "@" + msg.getUser().getScreen_name() + ":" + msg.getText()); if (!TextUtils.isEmpty(msg.getThumbnail_pic())) { Uri picUrl = null; String smallPath = FileManager.getFilePathFromUrl(msg.getThumbnail_pic(), FileLocationMethod.picture_thumbnail); String middlePath = FileManager.getFilePathFromUrl(msg.getBmiddle_pic(), FileLocationMethod.picture_bmiddle); String largePath = FileManager.getFilePathFromUrl(msg.getOriginal_pic(), FileLocationMethod.picture_large); if (ImageUtility.isThisBitmapCanRead(largePath)) { picUrl = Uri.fromFile(new File(largePath)); } else if (ImageUtility.isThisBitmapCanRead(middlePath)) { picUrl = Uri.fromFile(new File(middlePath)); } else if (ImageUtility.isThisBitmapCanRead(smallPath)) { picUrl = Uri.fromFile(new File(smallPath)); } if (picUrl != null) { shareIntent.putExtra(Intent.EXTRA_STREAM, picUrl); shareIntent.setType("image/*"); } } if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } } }
Example 13
Source File: Utility.java From iBeebo with GNU General Public License v3.0 | 5 votes |
public static void setShareIntent(Activity activity, ShareActionProvider mShareActionProvider, String content) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, content); if (Utility.isIntentSafe(activity, shareIntent) && mShareActionProvider != null) { mShareActionProvider.setShareIntent(shareIntent); } }
Example 14
Source File: MainActivity.java From cwac-security with Apache License 2.0 | 5 votes |
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.actions, menu); getMenuInflater().inflate(R.menu.common, menu); share= (ShareActionProvider)menu.findItem(R.id.share) .getActionProvider(); shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.msg_test)); share.setShareIntent(shareIntent); return(super.onCreateOptionsMenu(menu)); }
Example 15
Source File: VideoDetailActivity.java From android-viewer-for-khan-academy with GNU General Public License v3.0 | 4 votes |
private void prepareShareActionItem(MenuItem shareItem) { shareActionProvider = (ShareActionProvider) shareItem.getActionProvider(); shareActionProvider.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); shareActionProvider.setOnShareTargetSelectedListener(shareTargetSelectedListener); shareActionProvider.setShareIntent(prepareShareIntent(video)); }