Installing the Android SDK.
Inside your GitHub Account:
Go to Settings -> Developer Settings -> Personal Access Tokens -> Generate new token
Make sure to select the scope read:packages and Generate a token
After the token is generated, be sure to copy your new personal access token. It will not be accessible again. If the key is lost, the only option is to generate a new key.
To configure your token, a github.properties file containing your Github User ID and Personal Access Token must be placed in your project's root directory as shown below:
Alternatively, you can set the environment variables GPR_USER
and GPR_API_KEY
.
Next, define the Github Packages as a repository in the application module's build.gradle by adding the following section:
Note: If you have configured the project repositories via settings.gradle and changed the dependencyResolutionManagement to settings such as FAIL_ON_PROJECT_REPOS this may necessitate a change in where the repository is defined.
SnapOdds Operator provides you with the Snapping UI for Snapping Sport Events and returns you all required information about the sport event. After a successful snap you are free to use the result as you wish and present subsequent functionality to the user.
Permissions required by the Android SDK.
Snapscreen uses various Android permissions to function correctly. Each of the permissions listed below are necessary, (and automatically defined by the Snapscreen SDK):
Customizing displayed messages, colors and fonts.
To customize colors in SnapFragment
use the UIColorConfiguration
object on the Snapscreen instance.
To customize fonts in SnapFragment
, use the UIFontConfiguration
object on the Snapscreen instance.
To customize displayed messages in the SnapFragment
use the SnapUIConfiguration
object on the Snapscreen instance.
All desired customizations must be done prior to presenting the SnapFragment
or SnapActivity
. While it is possible to modify the configuration between presentations of the SnapFragment
, such modifications while SnapFragment
is present are not guaranteed to be respected.
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.
Steps to initialize Snapscreen functionality.
In order to initialize Snapscreen, the following class method must be called in your custom Application class in onCreate()
For best results, locational information must be provided for the user on initialization. Within the SDK, set the users country and US state information using the parameters country and usState. For US customers, country and state information must be provided. For non-US customers, at least country should be provided.
Once Snapscreen has been initialized, it can be retrieved by calling: