UiLifecycleHelper
最新版本的 SDK 已不再提供此課程。
有此級別的更新版本。前往查看 最新版本。

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.

伸延:Object
套件:facebook
建構函式
UiLifecycleHelper(Activity, StatusCallback)

Creates a new UiLifecycleHelper.

public UiLifecycleHelper(Activity activity, StatusCallback callback)
參數說明
activityThe Activity associated with the helper. If calling from a Fragment, use Fragment.getActivity()
callbackThe callback for Session status changes, can be null
執行個體方法
onCreate(Bundle)

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

public void onCreate(Bundle savedInstanceState)
參數說明
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)
參數說明
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)
參數說明
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)
參數說明
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)
參數說明
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