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 Sports Media provides a complete flow including the Snapping UI for snapping Sport Events and then displaying all available odds for the recognized sport event.
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
or OddsResultsFragment
use the UIColorConfiguration
object on the Snapscreen instance.
To customize fonts in SnapFragment
or OddsResultsFragment
, use the UIFontConfiguration
object on the Snapscreen instance.
To customize the displayed messages in SnapFragment
, use the UIConfiguration
object on the Snapscreen instance.
All desired customizations should be done prior to presenting the SnapFragment
. 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.
To customize displayed messages in the OddsResultsFragment
, use the OddDisplayUIConfiguration
object on the Snapscreen instance.
All desired customizations must be done prior to presenting the SnapActivity
and subsequently the OddsResultsFragment
. While it is also possible to modify the configuration between presentations of the OddsResultsFragment
, modifications initiated while the Fragment
is present are not guaranteed to be respected.
Ensure the SDK is initialized according to instructions listed in the section.
Retrieve an Intent for displaying the SnapActivity with your desired (or the default) SnapConfiguration
Start the intent for the SnapActivity
The following code illustrates 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 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"
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:
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: