Android SDK Version
  • java.lang.Object
    • com.facebook.share.ShareApi

public final class ShareApi
extends java.lang.Object
Provides an interface for sharing through the graph API. Using this class requires an access token in AccessToken.currentAccessToken that has been granted the "publish_actions" permission.
Constructor Summary
Constructor and Description
ShareApi(ShareContent shareContent)
Constructs a new instance.
Method Summary
Modifier and TypeMethod and Description
booleancanShare()
Returns true if the content can be shared.
java.lang.StringgetGraphNode()
Returns the graph node to share to.
java.lang.StringgetMessage()
Returns the message the person has provided through the custom dialog that will accompany the share content.
ShareContentgetShareContent()
Returns the content to be shared.
voidsetGraphNode(java.lang.String graphNode)
Sets the graph node to share to (this can be a user id, event id, page id, group id, album id, etc).
voidsetMessage(java.lang.String message)
Sets the message the person has provided through the custom dialog that will accompany the share content.
voidshare(FacebookCallback<Sharer.Result> callback)
Share the content.
static voidshare(ShareContent shareContent, FacebookCallback<Sharer.Result> callback)
Convenience method to share a piece of content.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail

ShareApi

public ShareApi(ShareContent shareContent)
Constructs a new instance.
Parameters:
shareContent - the content to share.
Method Detail

share

public static void share(ShareContent shareContent,
                         FacebookCallback<Sharer.Result> callback)
Convenience method to share a piece of content.
Parameters:
shareContent - the content to share.
callback - the callback to call once the share is complete.

getMessage

public java.lang.String getMessage()
Returns the message the person has provided through the custom dialog that will accompany the share content.
Returns:
the message.

setMessage

public void setMessage(java.lang.String message)
Sets the message the person has provided through the custom dialog that will accompany the share content.
Parameters:
message - the message.

getGraphNode

public java.lang.String getGraphNode()
Returns the graph node to share to.
Returns:
the graph node.

setGraphNode

public void setGraphNode(java.lang.String graphNode)
Sets the graph node to share to (this can be a user id, event id, page id, group id, album id, etc).
Parameters:
graphNode - the graph node to share to.

getShareContent

public ShareContent getShareContent()
Returns the content to be shared.
Returns:
the content to be shared.

canShare

public boolean canShare()
Returns true if the content can be shared. Warns if the access token is missing the publish_actions permission. Doesn't fail when this permission is missing, because the app could have been granted that permission in another installation.
Returns:
true if the content can be shared.

share

public void share(FacebookCallback<Sharer.Result> callback)
Share the content.
Parameters:
callback - the callback to call once the share is complete.