Skip to main content

Callbacks and Delegates

FSOnReadyListener

FSOnReadyListener can be used to get a callback when a session has started or resumed. This is useful for getting the current session ID or session URL as FS.getCurrentSession and FS.getCurrentSessionURL will return null when there is no active session.

The listener can be set with FS.setReadyListener (or removed by passing in null).

MethodDescription
onReady(FSSessionData sessionData)Called when the session has initialized and will begin or resume capturing.

FSStatusListener

Since 1.47
FSStatusListener can be used to get callbacks for a greater variety of events including disabled session status and SDK errors.

Status listeners can be registered and unregistered with FS.registerStatusListener and FS.unregisterStatusListener respectively. Unlike FSOnReadyListeners, you can have multiple FSStatusListeners registered concurrently.

MethodDescription
onSession(FSSessionData sessionData)Called when the session has initialized and will begin or resume capturing. This is equivalent to FSOnReadyListener#onReady.
onSessionDisabled(FSReason reason)Called when initialization has completed but FS will not begin capturing due to the session being disabled.
onFSError(FSReason error)Called when the SDK encounters an unrecoverable error and will cease or not begin to attempt capturing.
onFSDisabled(FSReason reason)Called when the SDK is disabled. This may be due to an incompatible device or OS version or due to FS not being instrumented.

For convenience, a DefaultFSStatusListener is provided that has empty implementations of each callback method in the interface that you may extend and only have to implement the callbacks you are interested in.

Additional Information

public static void FS.setReadyListener(FSOnReadyListener listener);
public static void FS.registerStatusListener(FSStatusListener listener);
public static void FS.unregisterStatusListener(FSStatusListener listener);

public interface FSOnReadyListener {
@UiThread
void onReady(FSSessionData sessionData);
}

public interface FSStatusListener {
@UiThread
void onSession(FSSessionData sessionData);

@UiThread
void onSessionDisabled(FSReason reason);

@UiThread
void onFSError(FSReason error);

@UiThread
void onFSDisabled(FSReason reason);
}

Create and set an FSOnReadyListener for an Application that logs the session playback URL

public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
FS.setReadyListener(new FSSessionReadyListener());
}

private static class FSSessionReadyListener implements FSOnReadyListener {
@Override
public void onReady(FSSessionData sessionData) {
Log.d("Fullstory", "Session URL is: " + sessionData.getCurrentSessionURL());
}
}
}

Register an FSStatusListener that logs status information

class MainActivity extends AppCompatActivity {
private final FSStatusListener listener = new StatusListener();

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
FS.registerStatusListener(listener);
}

@Override
protected void onDestroy() {
super.onDestroy();
FS.unregisterStatusListener(listener);
}

private static class StatusListener extends DefaultFSStatusListener {
@Override
public void onSession(FSSessionData sessionData) {
Log.d("Fullstory", "FS session URL:" + sessionData.getCurrentSessionURL());
}

@Override
public void onSessionDisabled(FSReason reason) {
Log.d("Fullstory", "Session disabled (" + reason.getCode() + "): " + reason.getMessage());
}

@Override
public void onFSError(FSReason error) {
Log.d("Fullstory", "FS Error (" + error.getCode() + "): " + error.getMessage());
}

@Override
public void onFSDisabled(FSReason reason) {
Log.d("Fullstory", "FS disabled (" + reason.getCode() + "): " + reason.getMessage());
}
}
}