The following section deals primarily with the code used in capture of live game information for SnapOdds Operator. If your use case requires game odds to be presented, the information captured by SnapOdds Operator is fed into SnapOdds Sports Media to correlate the game odds information, as described in Snapping Games and Presenting Odds
Ensure the SDK is initialized according to instructions listed in the Android Initialization section.
Ensure your class conforms to SnapFragmentResultListener
or SnapActivityResultListener
Instantiate SnapFragment
or SnapActivity
with your desired SnapConfiguration
and your SnapFragmentResultListener
or SnapActivityResultListener
Handle the result in your listener implementation.
The sport event that is returned contains the SportRadar Match ID as the property externalId. Several other ID providers like Kambi, Donbest, and more are available on request.
In order to snap a TV image and search for a sporting event, it is necessary to create and present an instance of SnapFragment
via the newInstance
class method. Snap settings can be customized by configuring the SnapConfiguration
passed to the initializer. The SnapFragmentResultListener
will receive a callback once a sporting event was successfully snapped.
The following code presents a SnapFragment
with the default configuration.
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 following method is called in SnapFragmentResultListener
:
After a successfull snap (and call of the listener method) the SnapFragment
automatically stops snapping. If you do not present any follow-up UI and you want to continue snapping, you can call continueSnapping()
on the SnapFragment
.
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"
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:
In addition to using the SnapFragment
directly, you can also use the SnapActivity
provided by the SDK. In that case, use the class method on SnapActivity
to retrieve an intent and pass a SnapActivityResultListener
. The SnapActivityResultListener
will receive a callback once a sporting event was successfully snapped.
The following code presents a SnapActivity with the default configuration.
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 following method is called in SnapActivityResultsListener:
After a successfull snap (and call of the listener method) the SnapFragment
(used for UI presentation in the SnapActivity
) automatically stops snapping. If you do not present any follow-up UI and you want to continue snapping, you can call continueSnapping()
on the SnapFragment
.
If you want to dismiss the activity and continue your own UI, you need to call activity.finish()
on the SnapActivity
.
It is recommended that you present the SnapFragment as a separate Activity.
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.