com.facebook.share.Sharer Java Examples
The following examples show how to use
com.facebook.share.Sharer.
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: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 6 votes |
public static void registerSharerCallback( final int requestCode, final CallbackManager callbackManager, final FacebookCallback<Sharer.Result> callback) { if (!(callbackManager instanceof CallbackManagerImpl)) { throw new FacebookException("Unexpected CallbackManager, " + "please use the provided Factory."); } ((CallbackManagerImpl) callbackManager).registerCallback( requestCode, new CallbackManagerImpl.Callback() { @Override public boolean onActivityResult(int resultCode, Intent data) { return handleActivityResult( requestCode, resultCode, data, getShareResultProcessor(callback)); } }); }
Example #2
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 6 votes |
private UploadContext( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) { // Store off the access token right away so that under no circumstances will we // end up with different tokens between phases. We will rely on the access token tracker // to cancel pending uploads. this.accessToken = AccessToken.getCurrentAccessToken(); this.videoUri = videoContent.getVideo().getLocalUrl(); this.title = videoContent.getContentTitle(); this.description = videoContent.getContentDescription(); this.ref = videoContent.getRef(); this.graphNode = graphNode; this.callback = callback; this.params = videoContent.getVideo().getParameters(); }
Example #3
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 6 votes |
public static synchronized void uploadAsync( ShareVideoContent videoContent, String graphNode, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { if (!initialized) { registerAccessTokenTracker(); initialized = true; } Validate.notNull(videoContent, "videoContent"); Validate.notNull(graphNode, "graphNode"); ShareVideo video = videoContent.getVideo(); Validate.notNull(video, "videoContent.video"); Uri videoUri = video.getLocalUrl(); Validate.notNull(videoUri, "videoContent.video.localUrl"); UploadContext uploadContext = new UploadContext(videoContent, graphNode, callback); uploadContext.initialize(); pendingUploads.add(uploadContext); enqueueUploadStart( uploadContext, 0); }
Example #4
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 #5
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; }
Example #6
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 #7
Source File: SendButton.java From kognitivo with Apache License 2.0 | 5 votes |
@Override protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() { final MessageDialog dialog; if (SendButton.this.getFragment() != null) { dialog = new MessageDialog(SendButton.this.getFragment() , getRequestCode()); } else { dialog = new MessageDialog(getActivity(), getRequestCode()); } return dialog; }
Example #8
Source File: ShareButton.java From kognitivo with Apache License 2.0 | 5 votes |
@Override protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() { final ShareDialog dialog; if (ShareButton.this.getFragment() != null) { dialog = new ShareDialog(ShareButton.this.getFragment() , getRequestCode()); } else { dialog = new ShareDialog(getActivity(), getRequestCode()); } return dialog; }
Example #9
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
static void invokeOnErrorCallback( FacebookCallback<Sharer.Result> callback, FacebookException ex) { logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_ERROR, ex.getMessage()); if (callback != null) { callback.onError(ex); } }
Example #10
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
static void invokeOnErrorCallback( FacebookCallback<Sharer.Result> callback, String message) { logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_ERROR, message); if (callback != null) { callback.onError(new FacebookException(message)); } }
Example #11
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
static void invokeOnErrorCallback( FacebookCallback<Sharer.Result> callback, GraphResponse response, String message) { logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_ERROR, message); if (callback != null) { callback.onError(new FacebookGraphResponseException(response, message)); } }
Example #12
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
static void invokeOnSuccessCallback( FacebookCallback<Sharer.Result> callback, String postId) { logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_SUCCEEDED, null); if (callback != null) { callback.onSuccess(new Sharer.Result(postId)); } }
Example #13
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
public static void invokeCallbackWithResults( FacebookCallback<Sharer.Result> callback, final String postId, final GraphResponse graphResponse) { FacebookRequestError requestError = graphResponse.getError(); if (requestError != null) { String errorMessage = requestError.getErrorMessage(); if (Utility.isNullOrEmpty(errorMessage)) { errorMessage = "Unexpected error sharing."; } invokeOnErrorCallback(callback, graphResponse, errorMessage); } else { invokeOnSuccessCallback(callback, postId); } }
Example #14
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 5 votes |
public static void invokeCallbackWithException( FacebookCallback<Sharer.Result> callback, final Exception exception) { if (exception instanceof FacebookException) { invokeOnErrorCallback(callback, (FacebookException) exception); return; } invokeCallbackWithError( callback, "Error preparing share content: " + exception.getLocalizedMessage()); }
Example #15
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 #16
Source File: VideoUploader.java From kognitivo with Apache License 2.0 | 4 votes |
public static synchronized void uploadAsync( ShareVideoContent videoContent, FacebookCallback<Sharer.Result> callback) throws FileNotFoundException { uploadAsync(videoContent, "me", callback); }
Example #17
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 4 votes |
static void invokeOnCancelCallback(FacebookCallback<Sharer.Result> callback) { logShareResult(AnalyticsEvents.PARAMETER_SHARE_OUTCOME_CANCELLED, null); if (callback != null) { callback.onCancel(); } }
Example #18
Source File: ShareInternalUtility.java From kognitivo with Apache License 2.0 | 4 votes |
public static void invokeCallbackWithError( FacebookCallback<Sharer.Result> callback, String error) { invokeOnErrorCallback(callback, error); }
Example #19
Source File: ShareButtonBase.java From kognitivo with Apache License 2.0 | 3 votes |
/** * Allows registration of a callback for when the share completes. This should be called * in the {@link android.app.Activity#onCreate(android.os.Bundle)} or * {@link android.support.v4.app.Fragment#onCreate(android.os.Bundle)} methods. * * @param callbackManager The {@link com.facebook.CallbackManager} instance that will be * handling results that are received via * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} * @param callback The callback that should be called to handle dialog completion. * @param requestCode The request code to use, this should be outside of the range of those * reserved for the Facebook SDK * {@link com.facebook.FacebookSdk#isFacebookRequestCode(int)}. */ public void registerCallback( final CallbackManager callbackManager, final FacebookCallback<Sharer.Result> callback, final int requestCode) { setRequestCode(requestCode); registerCallback(callbackManager, callback); }
Example #20
Source File: ShareButtonBase.java From kognitivo with Apache License 2.0 | 2 votes |
/** * Allows registration of a callback for when the share completes. This should be called * in the {@link android.app.Activity#onCreate(android.os.Bundle)} or * {@link android.support.v4.app.Fragment#onCreate(android.os.Bundle)} methods. * * @param callbackManager The {@link com.facebook.CallbackManager} instance that will be * handling results that are received via * {@link android.app.Activity#onActivityResult(int, int, android.content.Intent)} * @param callback The callback that should be called to handle dialog completion. */ public void registerCallback( final CallbackManager callbackManager, final FacebookCallback<Sharer.Result> callback) { ShareInternalUtility.registerSharerCallback(getRequestCode(), callbackManager, callback); }
Example #21
Source File: ShareButtonBase.java From kognitivo with Apache License 2.0 | votes |
abstract protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog();
Example #22
Source File: FacebookHelper.java From AndroidBlueprints with Apache License 2.0 | votes |
void onFacebookShareSuccess(Sharer.Result result);