Android SDK Version
Direct Known Subclasses:

public class LoginButton
extends FacebookButtonBase
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.
Nested Class Summary
Modifier and TypeClass and Description
protected class LoginButton.LoginClickListener 
static class LoginButton.ToolTipMode
The display modes for the login button tool tip.
Constructor Summary
Constructor and Description
LoginButton(Context context)
Create the LoginButton by inflating from XML
LoginButton(Context context, AttributeSet attrs)
Create the LoginButton by inflating from XML
LoginButton(Context context, AttributeSet attrs, int defStyle)
Create the LoginButton by inflating from XML and applying a style.
Method Summary
Modifier and TypeMethod and Description
voidclearPermissions()
Clears the permissions currently associated with this LoginButton.
protected voidconfigureButton(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) 
voiddismissToolTip()
Dismisses the Tooltip if it is currently visible
java.lang.StringgetAuthType()
Gets the authType being used.
DefaultAudiencegetDefaultAudience()
Gets the default audience to use when the user logs in.
protected intgetDefaultRequestCode() 
protected intgetDefaultStyleResource() 
LoginBehaviorgetLoginBehavior()
Gets the login behavior during authorization.
protected LoginButton.LoginClickListenergetNewLoginClickListener() 
longgetToolTipDisplayTime()
Gets the current amount of time (in ms) that the tool tip will be displayed to the user.
LoginButton.ToolTipModegetToolTipMode()
Return the current LoginButton.ToolTipMode for this LoginButton
protected voidonAttachedToWindow() 
protected voidonDetachedFromWindow() 
protected voidonDraw(Canvas canvas) 
protected voidonLayout(boolean changed, int left, int top, int right, int bottom) 
protected voidonMeasure(int widthMeasureSpec, int heightMeasureSpec) 
protected voidonVisibilityChanged(View changedView, int visibility) 
voidregisterCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager.
voidsetAuthType(java.lang.String authType)
Sets the authType to be used.
voidsetDefaultAudience(DefaultAudience defaultAudience)
Sets the default audience to use when the user logs in.
voidsetLoginBehavior(LoginBehavior loginBehavior)
Sets the login behavior during authorization.
voidsetLoginText(java.lang.String loginText) 
voidsetLogoutText(java.lang.String logoutText) 
voidsetPermissions(java.util.List<java.lang.String> permissions)
Set the permissions to use when the user logs in.
voidsetPermissions(java.lang.String... permissions)
Set the permissions to use when the user logs in.
voidsetPublishPermissions(java.util.List<java.lang.String> permissions)
Deprecated. 
use setPermissions
voidsetPublishPermissions(java.lang.String... permissions)
Deprecated. 
use setPermissions
voidsetReadPermissions(java.util.List<java.lang.String> permissions)
Deprecated. 
use setPermissions
voidsetReadPermissions(java.lang.String... permissions)
Deprecated. 
use setPermissions
voidsetToolTipDisplayTime(long displayTime)
Sets the amount of time (in milliseconds) that the tool tip will be shown to the user.
voidsetToolTipMode(LoginButton.ToolTipMode toolTipMode)
Sets the mode of the Tool Tip popup.
voidsetToolTipStyle(ToolTipPopup.Style toolTipStyle)
Sets the style (background) of the Tool Tip popup.
voidunregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail

LoginButton

public LoginButton(Context context)
Create the LoginButton by inflating from XML
See Also:
View#View(Context, AttributeSet)

LoginButton

public LoginButton(Context context,
                   AttributeSet attrs)
Create the LoginButton by inflating from XML
See Also:
View#View(Context, AttributeSet)

LoginButton

public LoginButton(Context context,
                   AttributeSet attrs,
                   int defStyle)
Create the LoginButton by inflating from XML and applying a style.
See Also:
View#View(Context, AttributeSet, int)
Method Detail

setLoginText

public void setLoginText(java.lang.String loginText)

setLogoutText

public void setLogoutText(java.lang.String logoutText)

setDefaultAudience

public void setDefaultAudience(DefaultAudience 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.
Parameters:
defaultAudience - the default audience value to use

getDefaultAudience

public DefaultAudience 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.
Returns:
the default audience value to use

setReadPermissions

public void setReadPermissions(java.util.List<java.lang.String> permissions)
Deprecated. use setPermissions
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).
Parameters:
permissions - the read permissions to use
Throws:
java.lang.UnsupportedOperationException - if setPublishPermissions has been called

setReadPermissions

public void setReadPermissions(java.lang.String... permissions)
Deprecated. use setPermissions
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).
Parameters:
permissions - the read permissions to use
Throws:
java.lang.UnsupportedOperationException - if setPublishPermissions has been called

setPermissions

public void setPermissions(java.util.List<java.lang.String> permissions)
Set the permissions to use when the user logs in. The permissions here can be either read or write permissions.
* 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).
Parameters:
permissions - the read and write permissions to use

setPermissions

public void setPermissions(java.lang.String... permissions)
Set the permissions to use when the user logs in. The permissions here can be either read or write permissions.
* 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).
Parameters:
permissions - the read and write permissions to use

setPublishPermissions

public void setPublishPermissions(java.util.List<java.lang.String> permissions)
Deprecated. use setPermissions
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).
Parameters:
permissions - the publish permissions to use
Throws:
java.lang.UnsupportedOperationException - if setReadPermissions has been called
java.lang.IllegalArgumentException - if permissions is null or empty

setPublishPermissions

public void setPublishPermissions(java.lang.String... permissions)
Deprecated. use setPermissions
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).
Parameters:
permissions - the publish permissions to use
Throws:
java.lang.UnsupportedOperationException - if setReadPermissions has been called
java.lang.IllegalArgumentException - if permissions is null or empty

clearPermissions

public void clearPermissions()
Clears the permissions currently associated with this LoginButton.

setLoginBehavior

public void setLoginBehavior(LoginBehavior loginBehavior)
Sets the login behavior during authorization. If null is specified, the default (LoginBehavior.NATIVE_WITH_FALLBACK will be used.
Parameters:
loginBehavior - The LoginBehavior that specifies what behaviors should be attempted during authorization.

getLoginBehavior

public LoginBehavior getLoginBehavior()
Gets the login behavior during authorization. If null is returned, the default (LoginBehavior.NATIVE_WITH_FALLBACK will be used.
Returns:
loginBehavior The LoginBehavior that specifies what behaviors should be attempted during authorization.

getAuthType

public java.lang.String getAuthType()
Gets the authType being used.
Returns:
the authType

setAuthType

public void setAuthType(java.lang.String authType)
Sets the authType to be used.
Parameters:
authType - the authType

setToolTipStyle

public void setToolTipStyle(ToolTipPopup.Style toolTipStyle)
Sets the style (background) of the Tool Tip popup. Currently a blue style and a black style are supported. Blue is default
Parameters:
toolTipStyle - The style of the tool tip popup.

setToolTipMode

public void setToolTipMode(LoginButton.ToolTipMode 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)
Parameters:
toolTipMode - The new mode for the tool tip

getToolTipMode

public LoginButton.ToolTipMode getToolTipMode()
Return the current LoginButton.ToolTipMode for this LoginButton

setToolTipDisplayTime

public void setToolTipDisplayTime(long displayTime)
Sets the amount of time (in milliseconds) that the tool tip will be shown to the user. The default is 6000L. Any value that is less than or equal to zero will cause the tool tip to be displayed indefinitely.
Parameters:
displayTime - The amount of time (in milliseconds) that the tool tip will be displayed to the user

getToolTipDisplayTime

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

dismissToolTip

public void dismissToolTip()
Dismisses the Tooltip if it is currently visible

registerCallback

public void registerCallback(CallbackManager callbackManager,
                             FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager.
Parameters:
callbackManager - The callback manager that will encapsulate the callback.
callback - The login callback that will be called on login completion.

unregisterCallback

public void unregisterCallback(CallbackManager callbackManager)
Unregisters a login callback to the given callback manager.
Parameters:
callbackManager - The callback manager that will encapsulate the callback.

onAttachedToWindow

protected void onAttachedToWindow()

onDraw

protected void onDraw(Canvas canvas)
Overrides:

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)

onDetachedFromWindow

protected void onDetachedFromWindow()

onVisibilityChanged

protected void onVisibilityChanged(View changedView,
                                   int visibility)

configureButton

protected void configureButton(Context context,
                               AttributeSet attrs,
                               int defStyleAttr,
                               int defStyleRes)
Overrides:

getNewLoginClickListener

protected LoginButton.LoginClickListener getNewLoginClickListener()

getDefaultStyleResource

protected int getDefaultStyleResource()

onMeasure

protected void onMeasure(int widthMeasureSpec,
                         int heightMeasureSpec)

getDefaultRequestCode

protected int getDefaultRequestCode()