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)
參數 | 說明 |
---|---|
activity | The Activity associated with the helper. If calling from a Fragment, use Fragment.getActivity() |
callback | The 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)
參數 | 說明 |
---|---|
savedInstanceState | The 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)
參數 | 說明 |
---|---|
requestCode | The request code |
resultCode | The result code |
data | The 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)
參數 | 說明 |
---|---|
requestCode | The request code |
resultCode | The result code |
data | The result data |
facebookDialogCallback | The 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)
參數 | 說明 |
---|---|
outState | The 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()