This demo project shows you how to integrate the CUE Audio Live Event SDK into your application.
First, make sure you get CUE Audio Maven credentials for your company or project. Add credentials and ULR to Maven bucket to local.properties at root of project:
com.cueaudio.maven.bucket=https://cueaudio.jfrog.io/cueaudio/libs-release-local
com.cueaudio.maven.username=<myusername>
com.cueaudio.maven.password=<mypassword>Secondly, check the CUE Audio Maven repository build.gradle file at root of project and add the following code if it's not present:
// Reading Maven credentials
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
maven {
url = properties.getProperty("com.cueaudio.maven.bucket")
credentials {
username = properties.getProperty("com.cueaudio.maven.username")
password = properties.getProperty("com.cueaudio.maven.password")
}
}
}
}After CUE Audio Maven setup finished, you can add CUE library as dependency of your app project:
dependencies {
implementation 'com.cueaudio:cuelive:3.+'
}If CUE has provided you with a customed-library, use it as dependency artifact id: implementation 'com.cueaudio:custom:3.0.0'
Note: always use the latest version of CUE library to get most recent features and fixes
Note: If you are using Android X, use version 3.+ instead of 2.+.
- In your Manifest, include:
<activity android:name="com.cueaudio.live.CUEActivity"
android:theme="@style/CUEAppTheme" />-
If you are using a custom design library, in app
gradlefile, replace the line:implementation project(':cue-design')with the name of the client design library:implementation project(':myClient-design'). -
Finally, in your fragment or activity, start
CUEActivityand we'll handle the rest.
final Intent i = new Intent(this, CUEActivity.class);
i.putExtra(CUEActivity.EXTRA_CUE_ENABLE_NAVIGATION_MENU, true);
startActivity(i);CUEActivity.EXTRA_CUE_ENABLE_NAVIGATION_MENU activity extra flag regulates whether in-built navigation menu will be shown or not. This extra is optional. By default it is set to true.
- In your manifest, you should also include the following code below. Make sure to replace {your_app_name} with your app name (no spaces) and to share this value with the CUE team.
<action android:name="android.intent.action.VIEW" />
...
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- CUE's deeplink domain and paths -->
<data android:scheme="https"/>
<data android:host="portal.cueaudio.com"/>
<data android:host="cueuc.com"/>
<data android:pathPrefix="/app/{your_app_name}"/>
...Then, add the following code to your Main Activity so that the CUE sdk can properly launch when the user visits a CUE deep link:
...
private lateinit var webViewController: WebViewController
...
override fun onCreate(savedInstanceState: Bundle?) {
...
webViewController = WebViewController(this)
...
handleIntent(intent)
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
handleIntent(intent)
}
private fun handleIntent(intent: Intent?) {
if (Intent.ACTION_VIEW == intent?.action) {
intent.data?.let { uri ->
val url = uri.toString()
if (url == "") {
println("Empty URL is not allowed")
return
}
try {
webViewController.navigateTo(url)
} catch (e: InvalidUrlError) {
// Show invalid URL error message
Toast.makeText(this, e.message, Toast.LENGTH_SHORT).show()
}
}
}
}
This demo project contains this code as an example within the MainActivity file.
Finally, in order for the deep links to work, please provide the SHA-256 fingerprint of your app. You can get it by following these instructions below:
If you're using Play App Signing, this is the safest way to get the right fingerprint (the "App signing certificate," not the upload key):
- Go to Google Play Console.
- Open the app.
- In the left menu: Setup → App integrity (older consoles: "Release management → App signing").
- In the App signing section, you'll see:
- App signing key certificate
- Upload key certificate
- Under App signing key certificate, copy the SHA-256 fingerprint.
⚠️ Important: For Digital Asset Links (assetlinks.json) you almost always want the App signing key fingerprint, not the upload key.
If you sign the app yourself with a local keystore (e.g. my-release-key.jks), you can extract the SHA-256 from that keystore.
On macOS / Linux:
keytool -list -v -keystore /path/to/your-keystore.jks -alias your_key_alias -storepass your_store_passwordOn Windows (PowerShell or cmd):
keytool -list -v -keystore C:\path\to\your-keystore.jks -alias your_key_alias -storepass your_store_passwordLook for the line:
SHA256: XX:XX:XX:...:XX
Copy that whole SHA256 line value (just the hex with colons).
⚠️ Note: Make sure this is the same keystore + alias used to sign the production builds, not the debug keystore.
If you're using the default Gradle signing config, you can use Android Studio's Signing Report.
- Open the project in Android Studio.
- Open the Gradle tool window (usually on the right).
- Expand:
:app(or your app module)Tasksandroid
- Double-click signingReport.
- In the Run window, you'll see entries like:
- Variant:
release/debug - SHA256: ...
- Variant:
Make sure you use the release variant (or whatever variant you use for production), then copy the SHA256 value.
If you already have a signed APK (or AAB), you can extract the cert directly.
- Ensure you have the Android SDK build tools installed (
apksigneris inbuild-tools/<version>/). - Run:
apksigner verify --print-certs /path/to/app-release.apkYou should see output like:
Signer #1 certificate SHA-256 digest: D0:E0:6F:61:2F:BE:ED:6F:C4:37:97:C5:16:15:6F:B1:8B:3B:88:AF:DA:69:1E:0F:FD:F7:D8:82:C9:DA:91:DD
Copy the SHA-256 digest (hex with colons).
âś… Tip: This method guarantees we're using the cert of the actual binary you signed.
CUE parameters can be overwritten and customized for your application. You can overwrite these parameters in strings.xml and colors.xml files in your project.
Note: If you overwrite CUE parameters in your project and also include a themed SDK other than the default
cuelive, this may cause incorrect behavior. Therefore, always ensure that, if you overwrite critical values likeapiKeyin your project, these values are set correctly for your client.
If you want to initiate the trigger from Push Notification or on an app start, use the CUEActivity.EXTRA_CUE_TRIGGER extra while setting the CUEActivity intent:
i.putExtra(CUEActivity.EXTRA_CUE_TRIGGER, "311.65.106");If you want to disable the Trivia prizes for loser/winner users, use next flags while launching CUEActivity:
i.putExtra(CUEActivity.EXTRA_IGNORE_TRIVIA_LOSER_PRIZE, true);
i.putExtra(CUEActivity.EXTRA_IGNORE_TRIVIA_WINNER_PRIZE, true);Trivia completed / canceled events are sent within LocalBroadcastReceiver with an actions:
CUETriviaBroadcastReceiver.ACTION_TRIVIA_COMPLETE/CUETriviaBroadcastReceiver.ACTION_TRIVIA_CANCELED
Use next code to subscribe for events:
private final CUETriviaBroadcastReceiver triviaEventReceiver = new CUETriviaBroadcastReceiver() {
@Override
public void onTriviaComplete(int score, int maxScore) {
Log.d(TAG, "onTriviaComplete: score=$score maxScore=$maxScore");
}
@Override
public void onTriviaCanceled() {
Log.d(TAG, "onTriviaCanceled");
}
};
final IntentFilter filter = new IntentFilter();
filter.addAction(CUETriviaBroadcastReceiver.ACTION_TRIVIA_COMPLETE);
filter.addAction(CUETriviaBroadcastReceiver.ACTION_TRIVIA_CANCELED);
context.registerReceiver(triviaEventReceiver, filter);Don't forget to unsubbscribe when you don't need to listen for event anymore:
context.unregisterReceiver(triviaEventReceiver);The cue_client_api_key key is what uniquely identifies a client. It is 32 alpha-numeric characters. This API Key must be the same for a client on both iOS and Android platforms.
The API Key also lets CUE modify the branding of a client remotely (on versions 2.3.0+). This way, if you are including the CUE SDK as a feature flag in multiple apps, you can simply use the -Default theme and do not need to provide custom branding in advance. Once a client purchases CUE services, we can update the SDK to a custom theme remotely. All you need to do is:
(1) Ensure that the same unique API Key overwrites the default API Key within your strings.xml file within your project:
<string name="cue_client_api_key">my_32_alpha_numeric_string</string>
(2) Fetch the CUE Theme associated with that API Key. You can do this in Application.onCreate():
CUEController.fetchCueTheme(this);If you store your API Key remotely rather than hardcode each client, you can pass the key in as a parameter. First, fetch the correct theme when you launch your app:
CUEController.fetchCueTheme(this, <#myClientApiKey#>);Next, launch this client's GUI:
final Intent i = new Intent(this, CUEActivity.class);
i.putExtra(CUEActivity.EXTRA_CUE_API_KEY, <#myClientApiKey#>);
startActivity(i);
Note: If you pull your client API Key from the server, it should be cached (e.g., UserDefaults) so that the user can access the light show even without a network connection.
You can pass optional EXTRA_CUE_PRIVACY flag to prevent collecting and sending to the server any user information. SDK initialization in this case looks like that:
private void launchApp() {
final Intent i = new Intent(this, CUEActivity.class);
i.putExtra(CUEActivity.EXTRA_CUE_PRIVACY, true);
startActivity(i);
}If you need different navigation bar color or controls primary color for CUEActivity, override colors in colors.xml:
<color name="cueColorPrimary">#ffffff</color>
<color name="colorPrimaryDark">#1a1e22</color>
<color name="colorAccent">#40c6ff</color>Alternatively the whole theme may be overridden by creating new one with CUEAppTheme as parent:
<style name="MyAppTheme" parent="@style/CUEAppTheme">
<!-- Customize your theme here. -->
</style>and set to CUEActivity in AndroidManifest.xml
<activity
android:name="com.cueaudio.live.CUEActivity"
android:theme="@style/MyAppTheme" />Note: For more information read Developers Android documentation
Overwrite in colors.xml with the following:
<color name="cue_primary_color">#00AEFF</color>
cue_primary_color is the theme color of the CUE SDK. This can be configured by CUE remotely as long as this app utilizes a unique API Key.
The image at the top of the CUE navigation menu. Overwrite by including an image titled cue_header.png in your drawables directory.
Include or overwrite the image or resource cue_header_background.jpg to change the background of the navigation header.
Overwrite the name that appears on the first page of the CUE Onboarding by specifying cue_app_name in your R.strings.
If you use the Facebook library Fresco within your project and initialize Fresco at the start of your application, set cue_use_fresco string resource to false:
<string name="cue_use_fresco">false</string>This ensures that Fresco is not initialized twice.
If you are using Sentry in your project, you will need to initialize Sentry with the CueAudio library. To initialize Sentry use method below with your own Sentry DNS key:
CUEInit.initSentry(dns: String)-
Once the CUE SDK is integrated and your project successfully compiles, launch the CUE portion of your app.
-
On the homescreen, please press the camera button to take a photo. Next, hold the button for at least three seconds to take a video. The photo and video should save successfully to your photos.
-
In the navigation menu, make sure the correct menu items are listed.
- Live
- Demo
- Help
- Info
- Exit (iOS only)
-
Next, go to
Demo. Complete the demo for all the services listed, which can be up to three items:Light Show,Selfie Cam, andTrivia. -
For
Light Show, your device should play an audio file and execute a demo light show in sync with the music, using the smartphone torch and screen. -
For
Selfie Cam, your device should initiate a countdown sequence while displaying the front-facing camera feed. Upon the countdown reaching0, you should be able to successfully Save, Retake, and Share your selfie. Please try all three features, although it is not necessary to actually share the selfie. You can simply ensure that the OS-specific share activity successfully launches. -
For
Trivia, your device should show a list of rules for a few seconds before launching a trivia game. Upon the completion of the game, your rank will be calculated. Since this is a demo game and not a live game, a generic "loser" message will be displayed after ~45 seconds. -
Finally, if CUE has provided you specific, additional audio files to test, please play these from a nearby computer or speaker while your CUE app is open to
Live. Your device should sync to the music. These custom tracks are client-specific, so a track prepared for one client will not work for another client unless explicitly designed to by CUE. To confirm that this track is for the correct client, make sure that client-specific information is displayed during the light show, such as the client's color scheme or logo.
Simply make sure the right version of CUE is specified in your build.gradle file:
dependencies {
implementation 'com.cueaudio:cuelive:3.+'
}FIX: Add the support for Java 1.8 to app's build.gradle:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}