UserSettingsFragment
Lớp này không còn khả dụng trong phiên bản gần đây nhất của SDK.

A Fragment that displays a Login/Logout button as well as the user's profile picture and name when logged in.

This Fragment will create and use the active session upon construction if it has the available data (if the app ID is specified in the manifest). It will also open the active session if it does not require user interaction (i.e. if the session is in the SessionState.CREATED_TOKEN_LOADED state. Developers can override the use of the active session by calling the UserSettingsFragment.setSession(com.facebook.Session) method.

Mở rộng:Fragment
Gói:widget
Xây dựng
UserSettingsFragment()
public UserSettingsFragment()
Phương thức thực thể
setSession(Session)

Use the supplied Session object instead of the active Session.

public void setSession(Session newSession)
Thông sốMô tả
newSessionThe Session object to use
onSessionStateChange(SessionState, Exception)

Called when the session state changes. Override this method to take action on session state changes.

protected void onSessionStateChange(SessionState state, Exception exception)
Thông sốMô tả
stateThe new state
exceptionAny exceptions that occurred during the state change
getSession()

Gets the current Session.

protected final Session getSession()
Returns
The current Session object.
isSessionOpen()

Determines whether the current session is open.

protected final boolean isSessionOpen()
Returns
True if the current session is open
getSessionState()

Gets the current state of the session or null if no session has been created.

protected final SessionState getSessionState()
Returns
The current state of the session
getAccessToken()

Gets the access token associated with the current session or null if no session has been created.

protected final String getAccessToken()
Returns
The access token
getExpirationDate()

Gets the date at which the current session will expire or null if no session has been created.

protected final Date getExpirationDate()
Returns
The date at which the current session will expire
closeSession()

Closes the current session.

protected final void closeSession()
closeSessionAndClearTokenInformation()

Closes the current session as well as clearing the token cache.

protected final void closeSessionAndClearTokenInformation()
getSessionPermissions()

Gets the permissions associated with the current session or null if no session has been created.

protected final List getSessionPermissions()
Returns
The permissions associated with the current session
openSession()

Opens a new session. This method will use the application id from the associated meta-data value and an empty list of permissions.

protected final void openSession()
openSessionForRead(String, List)

Opens a new session with read permissions. If either applicationID or permissions is null, this method will default to using the values from the associated meta-data value and an empty list respectively.

protected final void openSessionForRead(String applicationId, List permissions)
Thông sốMô tả
applicationIdThe applicationID, can be null
permissionsThe permissions list, can be null
openSessionForRead(String, List, SessionLoginBehavior, int)

Opens a new session with read permissions. If either applicationID or permissions is null, this method will default to using the values from the associated meta-data value and an empty list respectively.

protected final void openSessionForRead(String applicationId, List permissions, SessionLoginBehavior behavior, int activityCode)
Thông sốMô tả
applicationIdThe applicationID, can be null
permissionsThe permissions list, can be null
behaviorThe login behavior to use with the session
activityCodeThe activity code to use for the SSO activity
openSessionForPublish(String, List)

Opens a new session with publish permissions. If either applicationID is null, this method will default to using the value from the associated meta-data value. The permissions list cannot be null.

protected final void openSessionForPublish(String applicationId, List permissions)
Thông sốMô tả
applicationIdThe applicationID, can be null
permissionsThe permissions list, cannot be null
openSessionForPublish(String, List, SessionLoginBehavior, int)

Opens a new session with publish permissions. If either applicationID is null, this method will default to using the value from the associated meta-data value. The permissions list cannot be null.

protected final void openSessionForPublish(String applicationId, List permissions, SessionLoginBehavior behavior, int activityCode)
Thông sốMô tả
applicationIdThe applicationID, can be null
permissionsThe permissions list, cannot be null
behaviorThe login behavior to use with the session
activityCodeThe activity code to use for the SSO activity
setDefaultAudience(SessionDefaultAudience)

Sets the default audience to use when the session is opened. This value is only useful when specifying write permissions for the native login dialog.

public void setDefaultAudience(SessionDefaultAudience defaultAudience)
Thông sốMô tả
defaultAudienceThe default audience value to use
getDefaultAudience()

Gets the default audience to use when the session is opened. This value is only useful when specifying write permissions for the native login dialog.

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

Set the permissions to use when the session is opened. 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 session is open. If this is called after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the UserSettingsFragment is constructed, 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 managing the session explicitly).

public void setReadPermissions(List permissions)
Thông sốMô tả
permissionsThe read permissions to use
setReadPermissions(String)

Set the permissions to use when the session is opened. 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 session is open. If this is called after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the UserSettingsFragment is constructed, 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 managing the session explicitly).

public void setReadPermissions(String permissions)
Thông sốMô tả
permissionsThe read permissions to use
setPublishPermissions(List)

Set the permissions to use when the session is opened. 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 session is open. If this is called after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the LoginButton is constructed, 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 managing the session explicitly).

public void setPublishPermissions(List permissions)
Thông sốMô tả
permissionsThe read permissions to use
setPublishPermissions(String)

Set the permissions to use when the session is opened. 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 session is open. If this is called after the session is opened, and the list of permissions passed in is not a subset of the permissions granted during the authorization, it will log an error.

Since the session can be automatically opened when the LoginButton is constructed, 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 managing the session explicitly).

public void setPublishPermissions(String permissions)
Thông sốMô tả
permissionsThe read permissions to use
clearPermissions()

Clears the permissions currently associated with this LoginButton.

public void clearPermissions()
setLoginBehavior(SessionLoginBehavior)

Sets the login behavior for the session that will be opened. If null is specified, the default (SessionLoginBehavior.SSO_WITH_FALLBACK will be used.

public void setLoginBehavior(SessionLoginBehavior loginBehavior)
Thông sốMô tả
loginBehaviorThe SessionLoginBehavior that specifies what behaviors should be attempted during authorization.
getLoginBehavior()

Gets the login behavior for the session that will be opened. If null is returned, the default (SessionLoginBehavior.SSO_WITH_FALLBACK will be used.

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

Sets an OnErrorListener for this instance of UserSettingsFragment to call into when certain exceptions occur.

public void setOnErrorListener(OnErrorListener onErrorListener)
Thông sốMô tả
onErrorListenerThe listener object to set
getOnErrorListener()

Returns the current OnErrorListener for this instance of UserSettingsFragment.

public OnErrorListener getOnErrorListener()
Returns
The OnErrorListener
setSessionStatusCallback(StatusCallback)

Sets the callback interface that will be called whenever the status of the Session associated with this LoginButton changes.

public void setSessionStatusCallback(StatusCallback callback)
Thông sốMô tả
callbackThe callback interface
getSessionStatusCallback()

Sets the callback interface that will be called whenever the status of the Session associated with this LoginButton changes.

public StatusCallback getSessionStatusCallback()
Returns
The callback interface