UiLifecycleHelper
This class is no longer available in the most recent version of the SDK.
A more recent version of this class is available. Check out the latest version.

This class helps to create, automatically open (if applicable), save, and restore the Active Session in a way that is similar to Android UI lifecycles.

When using this class, clients MUST call all the public methods from the respective methods in either an Activity or Fragment. Failure to call all the methods can result in improperly initialized or uninitialized Sessions.

This class should also be used by Activities that will be displaying native dialogs provided by the Facebook application, in order to handle processing of the activity results generated by those dialogs.

Extends:Object
Package:facebook
Constructors
UiLifecycleHelper(Activity, StatusCallback)

Creates a new UiLifecycleHelper.

public UiLifecycleHelper(Activity activity, StatusCallback callback)
ParameterDescription
activityThe Activity associated with the helper. If calling from a Fragment, use Fragment.getActivity()
callbackThe callback for Session status changes, can be null
Instance Methods
onCreate(Bundle)

To be called from an Activity or Fragment's onCreate method.

public void onCreate(Bundle savedInstanceState)
ParameterDescription
savedInstanceStateThe previously saved state
onResume()

To be called from an Activity or Fragment's onResume method.

public void onResume()
onActivityResult(int, int, Intent)

To be called from an Activity or Fragment's onActivityResult method.

public void onActivityResult(int requestCode, int resultCode, Intent data)
ParameterDescription
requestCodeThe request code
resultCodeThe result code
dataThe result data
onActivityResult(int, int, Intent, Callback)

To be called from an Activity or Fragment's onActivityResult method, when the results of a FacebookDialog call are expected.

public void onActivityResult(int requestCode, int resultCode, Intent data, Callback facebookDialogCallback)
ParameterDescription
requestCodeThe request code
resultCodeThe result code
dataThe result data
facebookDialogCallbackThe callback for handling FacebookDialog results, can be null
onSaveInstanceState(Bundle)

To be called from an Activity or Fragment's onSaveInstanceState method.

public void onSaveInstanceState(Bundle outState)
ParameterDescription
outStateThe bundle to save state in
onPause()

To be called from an Activity or Fragment's onPause method.

public void onPause()
onStop()

To be called from an Activity or Fragment's onStop method.

public void onStop()
onDestroy()

To be called from an Activity or Fragment's onDestroy method.

public void onDestroy()
trackPendingDialogCall(PendingCall)

Register that we are expecting results from a call to the Facebook application (e.g., from a native dialog provided by the Facebook app). Activity results forwarded to onActivityResults will be parsed and handled if they correspond to this call. Only a single pending FacebookDialog call can be tracked at a time; attempting to track another one will cancel the first one.

public void trackPendingDialogCall(PendingCall pendingCall)
ParameterDescription
pendingCall
getAppEventsLogger()

Retrieves an instance of AppEventsLogger that can be used for the current Session, if any. Different instances may be returned if the current Session changes, so this value should not be cached for long periods of time -- always call getAppEventsLogger to get the right logger for the current Session. If no Session is currently available, this method will return null.

To ensure delivery of app events across Activity lifecycle events, calling Activities should be sure to call the onStop method.

public AppEventsLogger getAppEventsLogger()
Returns
An AppEventsLogger to use for logging app events