Snapping Games and Presenting Odds

Implementation

  1. Ensure the SDK is initialized according to instructions listed in the Android Initialization section.

  2. Retrieve an Intent for displaying the SnapActivity with your desired (or the default) SnapConfiguration

  3. Start the intent for the SnapActivity

Live Game Capture Code And Odds Display Code Example

The following code illustrates a SnapActivity with the default configuration.

val intent = SnapActivity.intentForSportsMedia(this, SnapConfiguration();
startActivity(intent)

If you do not want or need to customize the snapping configuration, you can also omit the configuration parameter.

Once a sporting event is successfully snapped, the OddsResultsFragment is automatically presented in the SnapActivity and the odds for the snapped game are presented.

If the sporting event is not successfully snapped, the values above are not returned, and an error message will appear in the viewfinder: "Your snap returned no results. Make sure your TV is visible in the viewfinder"

Camera Permissions Required before Presenting Snap

Applications must request user permission for camera access, and camera access is required for the app to function. For this reason, your application should be set to ask permission from the user to access the camera, and to receive said permission, before presenting the Snap UI. The following code will set your application to request and receive permission prior to opening Snap UI:

val isGranted = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
if (isGranted) {
    startActivity(Intent(context, MySnapActivity::class.java))
} else {
    requestPermissions(arrayOf(Manifest.permission.CAMERA), PERMISSION_REQUEST_CAMERA)
}

Recommendations

Present Snap as a separate Activity

It is recommended that you present the SnapFragment as a separate Activity.

Limit to portrait

Currently the Snap UI is only optimized for portrait orientation. It is recommended to present and limit the Activity containing a SnapFragment be limited to portrait orientation.

Last updated