private static void show( final FragmentWrapper fragmentWrapper, final ShareContent shareContent) { new ShareDialog(fragmentWrapper).show(shareContent); }
/** * Call this to check if the Share Dialog can be shown in a specific mode. * * @param mode Mode of the Share Dialog * @return True if the dialog can be shown in the passed in Mode */ public boolean canShow(ShareContent content, Mode mode) { return canShowImpl(content, (mode == Mode.AUTOMATIC) ? BASE_AUTOMATIC_MODE : mode); }
/** * Indicates whether it is possible to show the dialog for * {@link com.facebook.share.model.ShareContent} of the specified type. * * @param contentType Class of the intended {@link com.facebook.share.model.ShareContent} to * share. * @return True if the specified content type can be shown via the dialog */ public static boolean canShow(Class<? extends ShareContent> contentType) { return canShowWebTypeCheck(contentType) || canShowNative(contentType); }
shareDialog = new ShareDialog(this); shareDialog.registerCallback( callbackManager, shareCallback); canPresentShareDialog = ShareDialog.canShow( ShareLinkContent.class); canPresentShareDialogWithPhotos = ShareDialog.canShow( SharePhotoContent.class);
shareDialog = new ShareDialog(this); shareDialog.registerCallback(callbackManager, callback); messageDialog = new MessageDialog(this); messageDialog.registerCallback(callbackManager, callback);
/** * Helper to show the provided {@link com.facebook.share.model.ShareContent} using the provided * Fragment. No callback will be invoked. * * @param fragment android.support.v4.app.Fragment to use to share the provided content * @param shareContent Content to share */ public static void show( final Fragment fragment, final ShareContent shareContent) { show(new FragmentWrapper(fragment), shareContent); }
public void shareUsingAutomaticDialog() { if (playerChoice == INVALID_CHOICE || computerChoice == INVALID_CHOICE) { ShareContent content = getLinkContent(); // share the app if (shareDialog.canShow(content, ShareDialog.Mode.AUTOMATIC)) { shareDialog.show(content, ShareDialog.Mode.AUTOMATIC); } else { showError(R.string.share_dialog_error); } } else { ShareContent content = getThrowActionContent(); if (shareDialog.canShow(content, ShareDialog.Mode.AUTOMATIC)) { shareDialog.show(content, ShareDialog.Mode.AUTOMATIC); } else { showError(R.string.share_dialog_error); } } }
@Override protected FacebookDialogBase<ShareContent, Sharer.Result> getDialog() { final ShareDialog dialog; if (ShareButton.this.getFragment() != null) { dialog = new ShareDialog(ShareButton.this.getFragment(), getRequestCode()); } else if (ShareButton.this.getNativeFragment() != null) { dialog = new ShareDialog(ShareButton.this.getNativeFragment(), getRequestCode()); } else { dialog = new ShareDialog(getActivity(), getRequestCode()); } return dialog; } }
private static boolean canShowWebCheck(ShareContent content) { if (!canShowWebTypeCheck(content.getClass())) { return false; } if (content instanceof ShareOpenGraphContent) { final ShareOpenGraphContent ogContent = ((ShareOpenGraphContent) content); try { ShareInternalUtility.toJSONObjectForWeb(ogContent); } catch (Exception e) { Utility.logd( TAG, "canShow returned false because the content of the Opem Graph object" + " can't be shared via the web dialog", e); return false; } } return true; }
/** * Helper to show the provided {@link com.facebook.share.model.ShareContent} using the provided * Fragment. No callback will be invoked. * * @param fragment android.app.Fragment to use to share the provided content * @param shareContent Content to share */ public static void show( final android.app.Fragment fragment, final ShareContent shareContent) { show(new FragmentWrapper(fragment), shareContent); }
/** * Helper to show the provided {@link com.facebook.share.model.ShareContent} using the provided * Activity. No callback will be invoked. * * @param activity Activity to use to share the provided content * @param shareContent Content to share */ public static void show( final Activity activity, final ShareContent shareContent) { new ShareDialog(activity).show(shareContent); }
private void postPhoto() { Bitmap image = BitmapFactory.decodeResource(this.getResources(), R.drawable.icon); SharePhoto sharePhoto = new SharePhoto.Builder().setBitmap(image).build(); ArrayList<SharePhoto> photos = new ArrayList<>(); photos.add(sharePhoto); SharePhotoContent sharePhotoContent = new SharePhotoContent.Builder().setPhotos(photos).build(); if (canPresentShareDialogWithPhotos) { shareDialog.show(sharePhotoContent); } else if (hasPublishPermission()) { ShareApi.share(sharePhotoContent, shareCallback); } else { pendingAction = PendingAction.POST_PHOTO; // We need to get new permissions, then complete the action when we get called back. LoginManager.getInstance().logInWithPublishPermissions( this, Arrays.asList(PERMISSION)); } }
private void postStatusUpdate() { Profile profile = Profile.getCurrentProfile(); ShareLinkContent linkContent = new ShareLinkContent.Builder() .setContentTitle("Hello Facebook") .setContentDescription( "The 'Hello Facebook' sample showcases simple Facebook integration") .setContentUrl(Uri.parse("http://developers.facebook.com/docs/android")) .build(); if (canPresentShareDialog) { shareDialog.show(linkContent); } else if (profile != null && hasPublishPermission()) { ShareApi.share(linkContent, shareCallback); } else { pendingAction = PendingAction.POST_STATUS_UPDATE; } }