com.facebook.share.widget.ShareDialog Java Examples
The following examples show how to use
com.facebook.share.widget.ShareDialog.
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: SocialSharePlugin.java From social_share_plugin with BSD 2-Clause "Simplified" License | 5 votes |
private void facebookShare(String caption, String mediaPath) { final File media = new File(mediaPath); final Uri uri = FileProvider.getUriForFile(activity, activity.getPackageName() + ".social.share.fileprovider", media); final SharePhoto photo = new SharePhoto.Builder().setImageUrl(uri).setCaption(caption).build(); final SharePhotoContent content = new SharePhotoContent.Builder().addPhoto(photo).build(); final ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { channel.invokeMethod("onSuccess", null); Log.d("SocialSharePlugin", "Sharing successfully done."); } @Override public void onCancel() { channel.invokeMethod("onCancel", null); Log.d("SocialSharePlugin", "Sharing cancelled."); } @Override public void onError(FacebookException error) { channel.invokeMethod("onError", error.getMessage()); Log.d("SocialSharePlugin", "Sharing error occurred."); } }); if (ShareDialog.canShow(SharePhotoContent.class)) { shareDialog.show(content); } }
Example #2
Source File: SocialSharePlugin.java From social_share_plugin with BSD 2-Clause "Simplified" License | 5 votes |
private void facebookShareLink(String quote, String url) { final Uri uri = Uri.parse(url); final ShareLinkContent content = new ShareLinkContent.Builder().setContentUrl(uri).setQuote(quote).build(); final ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { channel.invokeMethod("onSuccess", null); Log.d("SocialSharePlugin", "Sharing successfully done."); } @Override public void onCancel() { channel.invokeMethod("onCancel", null); Log.d("SocialSharePlugin", "Sharing cancelled."); } @Override public void onError(FacebookException error) { channel.invokeMethod("onError", error.getMessage()); Log.d("SocialSharePlugin", "Sharing error occurred."); } }); if (ShareDialog.canShow(ShareLinkContent.class)) { shareDialog.show(content); } }
Example #3
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | 5 votes |
/** * Share content on facebook wall * * @param activity the activity * @param callback the callback to receive a result of this share * @param url the url you wish to share * @param quote the text you wish to associate with the url shared */ private void shareLinkOnFacebook(@NonNull final Activity activity, @NonNull final FacebookShareResultCallback callback, @NonNull String url, @Nullable String quote) { ShareDialog shareDialog = new ShareDialog(activity); shareDialog.registerCallback(mCallbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { callback.onFacebookShareSuccess(result); } @Override public void onCancel() { callback.onFacebookShareCancel(); } @Override public void onError(FacebookException error) { callback.onFacebookShareError(error); } }, RC_FACEBOOK_SHARE); if (ShareDialog.canShow(ShareLinkContent.class)) { ShareLinkContent linkContent = new ShareLinkContent.Builder().setContentUrl(Uri.parse(url)) .setQuote(quote) .build(); shareDialog.show(linkContent); } else { callback.onFacebookShareCannotShowDialog(); } }
Example #4
Source File: AbsModuleFragment.java From ONE-Unofficial with Apache License 2.0 | 5 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(getLayoutId(), null); ButterKnife.bind(this, view); shareDialog = new ShareDialog(this); CallbackManager callbackManager = CallbackManager.Factory.create(); shareDialog.registerCallback(callbackManager, new FacebookCallback<Sharer.Result>() { @Override public void onSuccess(Sharer.Result result) { } @Override public void onCancel() { } @Override public void onError(FacebookException error) { TextToast.shortShow(getString(R.string.share_fail)); } }); pager.setOnPageChangeListener(this); pager.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener<ViewPager>() { @Override public void onRefresh(PullToRefreshBase<ViewPager> refreshView) { refresh(); } }); adapter = new FragmentAdapter(getChildFragmentManager(), new ArrayList<AbsBaseFragment>()); pager.setAdapter(adapter); init(); instance=this; return view; }