LoginButton

A Log In/Log Out button that maintains login state and logs in/out for the app.

This control requires the app ID to be specified in the AndroidManifest.xml.

Extends:FacebookButtonBase
Package:widget
Constructors
LoginButton(Context)

Create the LoginButton by inflating from XML

public LoginButton(Context context)
ParameterDescription
context
LoginButton(Context, AttributeSet)

Create the LoginButton by inflating from XML

public LoginButton(Context context, AttributeSet attrs)
ParameterDescription
context
attrs
LoginButton(Context, AttributeSet, int)

Create the LoginButton by inflating from XML and applying a style.

public LoginButton(Context context, AttributeSet attrs, int defStyle)
ParameterDescription
context
attrs
defStyle
Instance Methods
setDefaultAudience(DefaultAudience)

Sets the default audience to use when the user logs in. This value is only useful when specifying publish permissions for the native login dialog.

public void setDefaultAudience(DefaultAudience defaultAudience)
ParameterDescription
defaultAudienceThe default audience value to use
getDefaultAudience()

Gets the default audience to use when the user logs in. This value is only useful when specifying publish permissions for the native login dialog.

public DefaultAudience getDefaultAudience()
Returns
The default audience value to use
setReadPermissions(List)

Set the permissions to use when the user logs in. The permissions here can only be read permissions. If any publish permissions are included, the login attempt by the user will fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Calling both setReadPermissions and setPublishPermissions on the same instance of LoginButton will result in an exception being thrown unless clearPermissions is called in between.

This method is only meaningful if called before the user logs in. If this is called after login, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

It's important to always pass in a consistent set of permissions to this method, or manage the setting of permissions outside of the LoginButton class altogether (by using the LoginManager explicitly).

public void setReadPermissions(List permissions)
ParameterDescription
permissionsThe read permissions to use
setReadPermissions(String)

Set the permissions to use when the user logs in. The permissions here can only be read permissions. If any publish permissions are included, the login attempt by the user will fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Calling both setReadPermissions and setPublishPermissions on the same instance of LoginButton will result in an exception being thrown unless clearPermissions is called in between.

This method is only meaningful if called before the user logs in. If this is called after login, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

It's important to always pass in a consistent set of permissions to this method, or manage the setting of permissions outside of the LoginButton class altogether (by using the LoginManager explicitly).

public void setReadPermissions(String permissions)
ParameterDescription
permissionsThe read permissions to use
setPublishPermissions(List)

Set the permissions to use when the user logs in. The permissions here should only be publish permissions. If any read permissions are included, the login attempt by the user may fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Calling both setReadPermissions and setPublishPermissions on the same instance of LoginButton will result in an exception being thrown unless clearPermissions is called in between.

This method is only meaningful if called before the user logs in. If this is called after login, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

It's important to always pass in a consistent set of permissions to this method, or manage the setting of permissions outside of the LoginButton class altogether (by using the LoginManager explicitly).

public void setPublishPermissions(List permissions)
ParameterDescription
permissionsThe publish permissions to use
setPublishPermissions(String)

Set the permissions to use when the user logs in. The permissions here should only be publish permissions. If any read permissions are included, the login attempt by the user may fail. The LoginButton can only be associated with either read permissions or publish permissions, but not both. Calling both setReadPermissions and setPublishPermissions on the same instance of LoginButton will result in an exception being thrown unless clearPermissions is called in between.

This method is only meaningful if called before the user logs in. If this is called after login, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

It's important to always pass in a consistent set of permissions to this method, or manage the setting of permissions outside of the LoginButton class altogether (by using the LoginManager explicitly).

public void setPublishPermissions(String permissions)
ParameterDescription
permissionsThe publish permissions to use
clearPermissions()

Clears the permissions currently associated with this LoginButton.

public void clearPermissions()
setLoginBehavior(LoginBehavior)

Sets the login behavior during authorization. If null is specified, the default (LoginBehavior.NATIVE_WITH_FALLBACK will be used.

public void setLoginBehavior(LoginBehavior loginBehavior)
ParameterDescription
loginBehaviorThe LoginBehavior that specifies what behaviors should be attempted during authorization.
getLoginBehavior()

Gets the login behavior during authorization. If null is returned, the default (LoginBehavior.NATIVE_WITH_FALLBACK will be used.

public LoginBehavior getLoginBehavior()
Returns
LoginBehavior The <a href='LoginBehavior'>LoginBehavior</a> that specifies what behaviors should be attempted during authorization.
setToolTipStyle(Style)

Sets the style (background) of the Tool Tip popup. Currently a blue style and a black style are supported. Blue is default

public void setToolTipStyle(Style toolTipStyle)
ParameterDescription
toolTipStyleThe style of the tool tip popup.
setToolTipMode(ToolTipMode)

Sets the mode of the Tool Tip popup. Currently supported modes are default (normal behavior), always_on (popup remains up until forcibly dismissed), and always_off (popup doesn't show)

public void setToolTipMode(ToolTipMode toolTipMode)
ParameterDescription
toolTipModeThe new mode for the tool tip
getToolTipMode()

Return the current LoginButton.ToolTipMode for this LoginButton

public ToolTipMode getToolTipMode()
Returns
The <a href='LoginButton.ToolTipMode'>LoginButton.ToolTipMode</a>
setToolTipDisplayTime(long)

Sets the amount of time (in milliseconds) that the tool tip will be shown to the user. The default is . Any value that is less than or equal to zero will cause the tool tip to be displayed indefinitely.

public void setToolTipDisplayTime(long displayTime)
ParameterDescription
displayTimeThe amount of time (in milliseconds) that the tool tip will be displayed to the user
getToolTipDisplayTime()

Gets the current amount of time (in ms) that the tool tip will be displayed to the user.

public long getToolTipDisplayTime()
Returns
The current amount of time (in ms) that the tool tip will be displayed.
dismissToolTip()

Dismisses the Tooltip if it is currently visible

public void dismissToolTip()
registerCallback(CallbackManager, FacebookCallback)

Registers a login callback to the given callback manager.

public void registerCallback(CallbackManager callbackManager, FacebookCallback callback)
ParameterDescription
callbackManagerThe callback manager that will encapsulate the callback.
callbackThe login callback that will be called on login completion.
getNewLoginClickListener()
protected LoginClickListener getNewLoginClickListener()