Android SDK Version
  • java.lang.Object
    • com.facebook.login.LoginManager
Direct Known Subclasses:

public class LoginManager
extends java.lang.Object
This class manages login and permissions for Facebook.
Method Summary
Modifier and TypeMethod and Description
protected LoginClient.RequestcreateLoginRequest(java.util.Collection<java.lang.String> permissions) 
protected LoginClient.RequestcreateReauthorizeRequest() 
java.lang.StringgetAuthType()
Getter for the authType
DefaultAudiencegetDefaultAudience()
Getter for the default audience.
protected IntentgetFacebookActivityIntent(LoginClient.Request request) 
static LoginManagergetInstance()
Getter for the login manager.
LoginBehaviorgetLoginBehavior()
Getter for the login behavior.
voidlogIn(Activity activity, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
voidlogIn(android.app.Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
voidlogIn(Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
voidlogInWithPublishPermissions(Activity activity, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
voidlogInWithPublishPermissions(android.app.Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
voidlogInWithPublishPermissions(Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
voidlogInWithReadPermissions(Activity activity, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
voidlogInWithReadPermissions(android.app.Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
voidlogInWithReadPermissions(Fragment fragment, java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
voidlogOut()
Logs out the user.
voidreauthorizeDataAccess(Activity activity)
Reauthorize data access
voidreauthorizeDataAccess(Fragment fragment)
Reauthorize data access
voidregisterCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback)
Registers a login callback to the given callback manager.
voidresolveError(Activity activity, GraphResponse response)
Starts the login process to resolve the error defined in the response.
voidresolveError(android.app.Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response.
voidresolveError(Fragment fragment, GraphResponse response)
Starts the login process to resolve the error defined in the response.
voidretrieveLoginStatus(Context context, LoginStatusCallback responseCallback)
Retrieves the login status for the user.
voidretrieveLoginStatus(Context context, long toastDurationMs, LoginStatusCallback responseCallback)
Retrieves the login status for the user.
LoginManagersetAuthType(java.lang.String authType)
Setter for the authType
LoginManagersetDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience.
LoginManagersetLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior.
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
Method Detail

getInstance

public static LoginManager getInstance()
Getter for the login manager.
Returns:
The login manager.

resolveError

public void resolveError(Activity activity,
                         GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
Parameters:
activity - The activity which is starting the login process.
response - The response that has the error.

resolveError

public void resolveError(Fragment fragment,
                         GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
Parameters:
fragment - The fragment which is starting the login process.
response - The response that has the error.

resolveError

public void resolveError(android.app.Fragment fragment,
                         GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
Parameters:
fragment - The android.app.Fragment which is starting the login process.
response - The response that has the error.

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.

getLoginBehavior

public LoginBehavior getLoginBehavior()
Getter for the login behavior.
Returns:
the login behavior.

setLoginBehavior

public LoginManager setLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior.
Parameters:
loginBehavior - The login behavior.
Returns:
The login manager.

getDefaultAudience

public DefaultAudience getDefaultAudience()
Getter for the default audience.
Returns:
The default audience.

setDefaultAudience

public LoginManager setDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience.
Parameters:
defaultAudience - The default audience.
Returns:
The login manager.

getAuthType

public java.lang.String getAuthType()
Getter for the authType
Returns:
The authType

setAuthType

public LoginManager setAuthType(java.lang.String authType)
Setter for the authType
Parameters:
authType - The authType
Returns:
The login manager.

logOut

public void logOut()
Logs out the user.

retrieveLoginStatus

public void retrieveLoginStatus(Context context,
                                LoginStatusCallback responseCallback)
Retrieves the login status for the user. This will return an access token for the app if a user is logged into the Facebook for Android app on the same device and that user had previously logged into the app. If an access token was retrieved then a toast will be shown telling the user that they have been logged in.
Parameters:
context - An Android context
responseCallback - The callback to be called when the request completes

retrieveLoginStatus

public void retrieveLoginStatus(Context context,
                                long toastDurationMs,
                                LoginStatusCallback responseCallback)
Retrieves the login status for the user. This will return an access token for the app if a user is logged into the Facebook for Android app on the same device and that user had previously logged into the app. If an access token was retrieved then a toast will be shown telling the user that they have been logged in.
Parameters:
context - An Android context
responseCallback - The callback to be called when the request completes
toastDurationMs - The duration to show the success toast in milliseconds

logInWithReadPermissions

public void logInWithReadPermissions(Fragment fragment,
                                     java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
Parameters:
fragment - The android.support.v4.app.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithReadPermissions

public void logInWithReadPermissions(android.app.Fragment fragment,
                                     java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
Parameters:
fragment - The android.app.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithReadPermissions

public void logInWithReadPermissions(Activity activity,
                                     java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested read permissions.
Parameters:
activity - The activity which is starting the login process.
permissions - The requested permissions.

reauthorizeDataAccess

public void reauthorizeDataAccess(Activity activity)
Reauthorize data access
Parameters:
activity - The activity which is starting the reauthorization process.

reauthorizeDataAccess

public void reauthorizeDataAccess(Fragment fragment)
Reauthorize data access
Parameters:
fragment - The android.support.v4.app.Fragment starting the reauthorization process.

logInWithPublishPermissions

public void logInWithPublishPermissions(Fragment fragment,
                                        java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
Parameters:
fragment - The android.support.v4.app.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithPublishPermissions

public void logInWithPublishPermissions(android.app.Fragment fragment,
                                        java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
Parameters:
fragment - The android.app.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithPublishPermissions

public void logInWithPublishPermissions(Activity activity,
                                        java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested publish permissions.
Parameters:
activity - The activity which is starting the login process.
permissions - The requested permissions.

logIn

public void logIn(Fragment fragment,
                  java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
Parameters:
fragment - The android.support.v4.app.Fragment which is starting the login process.
permissions - The requested permissions.

logIn

public void logIn(android.app.Fragment fragment,
                  java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
Parameters:
fragment - The android.app.Fragment which is starting the login process.
permissions - The requested permissions.

logIn

public void logIn(Activity activity,
                  java.util.Collection<java.lang.String> permissions)
Logs the user in with the requested permissions.
Parameters:
activity - The activity which is starting the login process.
permissions - The requested permissions.

createLoginRequest

protected LoginClient.Request createLoginRequest(java.util.Collection<java.lang.String> permissions)

createReauthorizeRequest

protected LoginClient.Request createReauthorizeRequest()

getFacebookActivityIntent

protected Intent getFacebookActivityIntent(LoginClient.Request request)