Android SDK Version


public class LoginManager
This class manages login and permissions for Facebook.
Nested Class Summary
Modifier and TypeClassDescription
public final classLoginManager.FacebookLoginActivityResultContract
The ActivityResultContract object for login. This contract can be used as the parameter for registerForActivityResult.
public classLoginManager.Companion
Constructor Summary
ConstructorDescription
LoginManager()
Method Summary
Modifier and TypeMethodDescription
final LoginBehaviorgetLoginBehavior() The login behavior.
final UnitsetLoginBehavior(LoginBehavior loginBehavior)
final DefaultAudiencegetDefaultAudience() The default audience.
final UnitsetDefaultAudience(DefaultAudience defaultAudience)
final StringgetAuthType() The authType
final UnitsetAuthType(String authType)
final LoginTargetAppgetLoginTargetApp() The login target app.
final UnitsetLoginTargetApp(LoginTargetApp loginTargetApp)
final BooleangetIsFamilyLogin() Determines whether we are using the cross Family of Apps login experience.
final UnitsetIsFamilyLogin(Boolean isFamilyLogin)
final BooleangetShouldSkipAccountDeduplication() Determines if we should skip deduplicating account during x-FoA login.
final UnitsetShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)
final UnitresolveError(Activity activity, GraphResponse response) Starts the login process to resolve the error defined in the response.
final UnitresolveError(Fragment fragment, GraphResponse response) Starts the login process to resolve the error defined in the response.
final UnitresolveError(Fragment fragment, CallbackManager callbackManager, GraphResponse response) Starts the login process to resolve the error defined in the response.
final UnitresolveError(Fragment fragment, GraphResponse response) Starts the login process to resolve the error defined in the response.
final UnitresolveError(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, GraphResponse response) Starts the login process to resolve the error defined in the response.
final UnitregisterCallback(CallbackManager callbackManager, FacebookCallback<LoginResult> callback) Registers a login callback to the given callback manager.
final UnitunregisterCallback(CallbackManager callbackManager) Unregisters a login callback to the given callback manager.
BooleanonActivityResult(Integer resultCode, Intent data, FacebookCallback<LoginResult> callback)
BooleanonActivityResult(Integer resultCode, Intent data)
final LoginManagersetLoginBehavior(LoginBehavior loginBehavior) Setter for the login behavior.
final LoginManagersetLoginTargetApp(LoginTargetApp targetApp) Setter for the login target app.
final LoginManagersetDefaultAudience(DefaultAudience defaultAudience) Setter for the default audience.
final LoginManagersetAuthType(String authType) Setter for the authType
final LoginManagersetMessengerPageId(String messengerPageId) Setter for the messengerPageId
final LoginManagersetResetMessengerState(Boolean resetMessengerState) Setter for the resetMessengerState.
final LoginManagersetFamilyLogin(Boolean isFamilyLogin) Setter for whether we are using cross Family of Apps login
final LoginManagersetShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication) Setter for whether we are skipping deduplicating account during x-FoA login.
UnitlogOut() Logs out the user.
final UnitretrieveLoginStatus(Context context, LoginStatusCallback responseCallback) Retrieves the login status for the user.
final UnitretrieveLoginStatus(Context context, Long toastDurationMs, LoginStatusCallback responseCallback) Retrieves the login status for the user.
final UnitlogInWithReadPermissions(Fragment fragment, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogInWithReadPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogInWithReadPermissions(Fragment fragment, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogInWithReadPermissions(Activity activity, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogInWithReadPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogInWithConfiguration(Fragment fragment, LoginConfiguration loginConfig) Logs the user in with the requested configuration.
final UnitloginWithConfiguration(Activity activity, LoginConfiguration loginConfig) Logs the user in with the requested configuration.
final UnitreauthorizeDataAccess(Activity activity) Reauthorize data access
final UnitreauthorizeDataAccess(Fragment fragment) Reauthorize data access
final UnitlogInWithPublishPermissions(Fragment fragment, Collection<String> permissions) Logs the user in with the requested publish permissions.
final UnitlogInWithPublishPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions) Logs the user in with the requested publish permissions.
final UnitlogInWithPublishPermissions(Fragment fragment, Collection<String> permissions) Logs the user in with the requested publish permissions.
final UnitlogInWithPublishPermissions(Activity activity, Collection<String> permissions) Logs the user in with the requested publish permissions.
final UnitlogInWithPublishPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions) Logs the user in with the requested read permissions.
final UnitlogIn(Fragment fragment, Collection<String> permissions) Logs the user in with the requested permissions.
final UnitlogIn(Fragment fragment, Collection<String> permissions, String loggerID) Logs the user in with the requested permissions.
final UnitlogIn(Fragment fragment, Collection<String> permissions) Logs the user in with the requested permissions.
final UnitlogIn(Fragment fragment, Collection<String> permissions, String loggerID) Logs the user in with the requested permissions.
final UnitlogIn(FragmentWrapper fragment, Collection<String> permissions) Logs the user in with the requested permissions.
final UnitlogIn(FragmentWrapper fragment, Collection<String> permissions, String loggerID) Logs the user in with the requested permissions.
final UnitlogIn(Activity activity, Collection<String> permissions) Logs the user in with the requested permissions.
final UnitlogIn(FragmentWrapper fragment, LoginConfiguration loginConfig) Logs the user in with the requested login configuration.
final UnitlogIn(Activity activity, LoginConfiguration loginConfig) Logs the user in with the requested configuration.
final UnitlogIn(Activity activity, Collection<String> permissions, String loggerID) Logs the user in with the requested permissions.
final UnitlogIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions, String loggerID) Logs the user in with the requested permissions.
final UnitlogIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions) Logs the user in with the requested permissions.
final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract(CallbackManager callbackManager, String loggerID) Create the ActivityResultContract object for login.
final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract(CallbackManager callbackManager) Create the ActivityResultContract object for login.
final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract() Create the ActivityResultContract object for login.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Constructor Detail

LoginManager

LoginManager()
Method Detail

getLoginBehavior

 final LoginBehaviorgetLoginBehavior()
The login behavior.

setLoginBehavior

 final UnitsetLoginBehavior(LoginBehavior loginBehavior)

getDefaultAudience

 final DefaultAudiencegetDefaultAudience()
The default audience.

setDefaultAudience

 final UnitsetDefaultAudience(DefaultAudience defaultAudience)

getAuthType

 final StringgetAuthType()
The authType

setAuthType

 final UnitsetAuthType(String authType)

getLoginTargetApp

 final LoginTargetAppgetLoginTargetApp()
The login target app.

setLoginTargetApp

 final UnitsetLoginTargetApp(LoginTargetApp loginTargetApp)

getIsFamilyLogin

 final BooleangetIsFamilyLogin()
Determines whether we are using the cross Family of Apps login experience. True if using cross Family of Apps login

setIsFamilyLogin

 final UnitsetIsFamilyLogin(Boolean isFamilyLogin)

getShouldSkipAccountDeduplication

 final BooleangetShouldSkipAccountDeduplication()
Determines if we should skip deduplicating account during x-FoA login. True if Account deduplication is opted out in Family of Apps login

setShouldSkipAccountDeduplication

 final UnitsetShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)

resolveError

 final UnitresolveError(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

@Deprecated(message = ) final UnitresolveError(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.
This method is deprecated and it's better to use the method with a CallbackManager as the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity result APIs so you won't need to override onActivityResult method on the fragment.
Parameters:
fragment - The fragment which is starting the login process.
response - The response that has the error.

resolveError

 final UnitresolveError(Fragment fragment, CallbackManager callbackManager, 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.
callbackManager - The callback manager which is used to register callbacks.
response - The response that has the error.

resolveError

 final UnitresolveError(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.

resolveError

 final UnitresolveError(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, GraphResponse response)
Starts the login process to resolve the error defined in the response. The registered login callbacks will be called on completion.
Parameters:
activityResultRegistryOwner - The activity result register owner.
callbackManager - The callback manager from Facebook SDK.
response - The response that has the error.

registerCallback

 final UnitregisterCallback(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

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

onActivityResult

@JvmOverloads() BooleanonActivityResult(Integer resultCode, Intent data, FacebookCallback<LoginResult> callback)

onActivityResult

@JvmOverloads() BooleanonActivityResult(Integer resultCode, Intent data)

setLoginBehavior

 final LoginManagersetLoginBehavior(LoginBehavior loginBehavior)
Setter for the login behavior.
Parameters:
loginBehavior - The login behavior.

setLoginTargetApp

 final LoginManagersetLoginTargetApp(LoginTargetApp targetApp)
Setter for the login target app.
Parameters:
targetApp - The login target app.

setDefaultAudience

 final LoginManagersetDefaultAudience(DefaultAudience defaultAudience)
Setter for the default audience.
Parameters:
defaultAudience - The default audience.

setAuthType

 final LoginManagersetAuthType(String authType)
Setter for the authType
Parameters:
authType - The authType

setMessengerPageId

 final LoginManagersetMessengerPageId(String messengerPageId)
Setter for the messengerPageId
Parameters:
messengerPageId - The messengerPageId

setResetMessengerState

 final LoginManagersetResetMessengerState(Boolean resetMessengerState)
Setter for the resetMessengerState. For developers of the app only.
Parameters:
resetMessengerState - Whether to enable resetMessengerState

setFamilyLogin

 final LoginManagersetFamilyLogin(Boolean isFamilyLogin)
Setter for whether we are using cross Family of Apps login
Parameters:
isFamilyLogin - Whether we are using cross Family of Apps login

setShouldSkipAccountDeduplication

 final LoginManagersetShouldSkipAccountDeduplication(Boolean shouldSkipAccountDeduplication)
Setter for whether we are skipping deduplicating account during x-FoA login.
Parameters:
shouldSkipAccountDeduplication - Whether we want to opt out account deduplication experience in Family of Apps login

logOut

UnitlogOut()
Logs out the user.

retrieveLoginStatus

 final UnitretrieveLoginStatus(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

 final UnitretrieveLoginStatus(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
toastDurationMs - The duration to show the success toast in milliseconds
responseCallback - The callback to be called when the request completes

logInWithReadPermissions

@Deprecated(message = ) final UnitlogInWithReadPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested read permissions.
This method is deprecated and it's better to use the method with a CallbackManager as the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity result APIs so you won't need to override onActivityResult method on the fragment.
Parameters:
fragment - The androidx.fragment.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithReadPermissions

 final UnitlogInWithReadPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions.
Parameters:
fragment - The androidx.fragment.Fragment which is starting the login process.
callbackManager - The callback manager which is used to register callbacks.
permissions - The requested permissions.

logInWithReadPermissions

 final UnitlogInWithReadPermissions(Fragment fragment, Collection<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

 final UnitlogInWithReadPermissions(Activity activity, Collection<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.

logInWithReadPermissions

 final UnitlogInWithReadPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions.
Parameters:
activityResultRegistryOwner - The activity result register owner.
callbackManager - The callback manager from Facebook SDK.
permissions - The requested permissions.

logInWithConfiguration

 final UnitlogInWithConfiguration(Fragment fragment, LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
Parameters:
fragment - The android.support.v4.app.Fragment which is starting the login process.
loginConfig - The login configuration

loginWithConfiguration

 final UnitloginWithConfiguration(Activity activity, LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
Parameters:
activity - The activity which is starting the login process.
loginConfig - The login configuration

reauthorizeDataAccess

 final UnitreauthorizeDataAccess(Activity activity)
Reauthorize data access
Parameters:
activity - The activity which is starting the reauthorization process.

reauthorizeDataAccess

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

logInWithPublishPermissions

@Deprecated(message = ) final UnitlogInWithPublishPermissions(Fragment fragment, Collection<String> permissions)
Logs the user in with the requested publish permissions.
This method is deprecated and it's better to use the method with a CallbackManager as the second parameter. The new method with the CallbackManager as a parameter will use AndroidX activity result APIs so you won't need to override onActivityResult method on the fragment.
Parameters:
fragment - The androidx.fragment.Fragment which is starting the login process.
permissions - The requested permissions.

logInWithPublishPermissions

 final UnitlogInWithPublishPermissions(Fragment fragment, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested publish permissions.
Parameters:
fragment - The androidx.fragment.Fragment which is starting the login process.
callbackManager - The callback manager which is used to register callbacks.
permissions - The requested permissions.

logInWithPublishPermissions

 final UnitlogInWithPublishPermissions(Fragment fragment, Collection<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

 final UnitlogInWithPublishPermissions(Activity activity, Collection<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.

logInWithPublishPermissions

 final UnitlogInWithPublishPermissions(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested read permissions.
Parameters:
activityResultRegistryOwner - The activity result register owner.
callbackManager - The callback manager from Facebook SDK.
permissions - The requested permissions.

logIn

 final UnitlogIn(Fragment fragment, Collection<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

 final UnitlogIn(Fragment fragment, Collection<String> permissions, String loggerID)
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.
loggerID - Override the default logger ID for the request

logIn

 final UnitlogIn(Fragment fragment, Collection<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

 final UnitlogIn(Fragment fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
Parameters:
fragment - The android.app.Fragment which is starting the login process.
permissions - The requested permissions.
loggerID - Override the default logger ID for the request

logIn

 final UnitlogIn(FragmentWrapper fragment, Collection<String> permissions)
Logs the user in with the requested permissions.
Parameters:
fragment - The fragment which is starting the login process.
permissions - The requested permissions.

logIn

 final UnitlogIn(FragmentWrapper fragment, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
Parameters:
fragment - The fragment which is starting the login process.
permissions - The requested permissions.
loggerID - Override the default logger ID for the request

logIn

 final UnitlogIn(Activity activity, Collection<String> permissions)
Logs the user in with the requested permissions.
Parameters:
activity - The activity which is starting the login process.
permissions - The requested permissions.

logIn

 final UnitlogIn(FragmentWrapper fragment, LoginConfiguration loginConfig)
Logs the user in with the requested login configuration.
Parameters:
fragment - The fragment which is starting the login process.
loginConfig - The login config of the request

logIn

 final UnitlogIn(Activity activity, LoginConfiguration loginConfig)
Logs the user in with the requested configuration.
Parameters:
activity - The activity which is starting the login process.
loginConfig - The login config of the request

logIn

 final UnitlogIn(Activity activity, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
Parameters:
activity - The activity which is starting the login process.
permissions - The requested permissions.
loggerID - Override the default logger ID for the request

logIn

 final UnitlogIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions, String loggerID)
Logs the user in with the requested permissions.
Parameters:
activityResultRegistryOwner - The activity result register owner.
callbackManager - The callback manager from Facebook SDK.
permissions - The requested permissions.
loggerID - Override the default logger ID for the request

logIn

 final UnitlogIn(ActivityResultRegistryOwner activityResultRegistryOwner, CallbackManager callbackManager, Collection<String> permissions)
Logs the user in with the requested permissions.
Parameters:
activityResultRegistryOwner - The activity result register owner.
callbackManager - The callback manager from Facebook SDK.
permissions - The requested permissions.

createLogInActivityResultContract

@JvmOverloads() final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract(CallbackManager callbackManager, String loggerID)
Create the ActivityResultContract object for login. This contract can be used as the parameter for registerForActivityResult.
For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher
Parameters:
callbackManager - the callback manager to register login callbacks.
loggerID - the logger Id for the login request.

createLogInActivityResultContract

@JvmOverloads() final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract(CallbackManager callbackManager)
Create the ActivityResultContract object for login. This contract can be used as the parameter for registerForActivityResult.
For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher
Parameters:
callbackManager - the callback manager to register login callbacks.

createLogInActivityResultContract

@JvmOverloads() final LoginManager.FacebookLoginActivityResultContractcreateLogInActivityResultContract()
Create the ActivityResultContract object for login. This contract can be used as the parameter for registerForActivityResult.
For example, in an AndroidX activity/fragment:
// onCreate val launcher = registerForActivityResult( loginManager.createLogInActivityResultContract(callbackManager)) {...} // when user click the login button launcher.launch(permissions)
In Jetpack Compose, we can use
rememberLauncherForActivityResult( contract = loginManager.createLogInActivityResultContract(callbackManager, null), onResult = {...} )
to create the launcher