Java API Reference

The GameBench Java API is intended for native Android apps. The API is a set of static methods on the GameBench class which is in the com.gamebench.sdk package which is in libgamebench.aar.

Sessions

static boolean startSession(String title)
Starts a new capture session, with an optional title.

static String getSessionId()
Returns the UUID of the active session, or null if there isn’t one.

static boolean stopSession()
Stops the current capture session.

static void upload(UploadCallback callback)
Uploads any outstanding sessions to the endpoint configured in the UI. After successful upload the session data will be removed from the device. Must be called without an active session.

NB: The callback is a nullable pointer to the UploadCallback interface which contains the single method void uploadComplete(int numSessionsUploaded, String error);

Metric capture

All metrics may be captured at set intervals and/or with the captureNow() method. Metric capture has very low overhead and is asynchronous, it should not affect your app’s observed performance.

static void setMetricInterval(String metric, float value)
Enable and set the capture interval in seconds for the given metric type. Can be called with or without an active capture session. Use an interval of 0 or less to disable.

static void captureNow(String metric)
Capture and write out the given metric now.

Note that screenshots are a type of metric (see the SS values in the Configuration page). To capture a screenshot at 50% the screen resolution you could write captureNow("SS1").

Markers

To isolate specific areas of gameplay such as levels or battles, GameBench provides markers functionality. For example, to isolate performance data during a particular game level, you can call recordStartMarker() when the level begins and recordStopMarker() when the level is completed.

static void recordStartMarker(String name, String group)
Record a ‘start’ marker with the given name and marker group (optional).

static void recordStopMarker(String name, String group)
Record a ‘stop’ marker with the given name.

static void recordLaunchCompleteMarker()
Record a ’launch complete’ marker that has a special significance in the web dashboard.

Tags

static void setTag(String name, String value)
Set a tag in the tags collection

static void removeTag(String name)
Remove a tag from the tags collection

Other Configuration

Hopefully self-explanatory but refer to the Configuration page if not.

static void setUrl(String url);
static void setUser(String user);
static void setToken(String token);
static void setAutoSessionEnabled(boolean enabled);
static void setVerboseLoggingEnabled(boolean enabled);
Last updated on