Skip to main content
Platform
Language

Integrate the Mobile Camera

In this example, we will show you how to initialize the CreativeEditor SDK's mobile camera in your Android app.

Explore a full code sample on GitHub.

Adding dependency#

Add IMG.LY maven repository to the list of maven urls in the settings.gradle file.

Add camera dependency in the build.gradle file of your application module.

Requirements#

In order to use the mobile camera, your application should meet the following requirements:

  • buildFeatures.compose should be true, as the camera is written in Jetpack Compose.
  • composeOptions.kotlinCompilerExtensionVersion should match the kotlin version. Use the official compatibility map in here.
  • compose-bom version is 2023.05.01 or higher if your project uses Jetpack Compose dependencies. Note that using lower versions may cause crashes and issues in your own compose code, as our version will override yours. In case you are not using BOM, you can find the BOM to compose library version mapping in here.
  • Kotlin version is 1.9.10 or higher.
  • minSdk is 24 (Android 7) or higher.

By default, the mobile camera supports following ABIs: arm64-v8a, armeabi-v7a, x86_64 and x86. If you want to filter out some of the ABIs, use abiFilters.

Usage#

This example shows the basic usage of the camera using the Activity Result APIs.

In this integration example, on tapping the button, the ActivityResultLauncher is launched, presenting the camera Activity.

Initialization#

The camera input is initialized with EngineConfiguration. You need to provide the license key that you received from IMG.LY. Optionally, you can provide a unique ID tied to your application's user. This helps us accurately calculate monthly active users (MAU) and it is especially useful when one person uses the app on multiple devices with a sign-in feature, ensuring they're counted once.

CaptureVideo ActivityResultContract#

Here, we register a request to start the Camera designated by the CaptureVideo contract.

Result#

The CaptureVideo contract's output is a CameraResult?. It is null when the camera is dismissed by the user and non-null when the user has recorded videos. CameraResult is a sealed interface and the result can be obtained by casting it appropriately.

That is all. For more than basic configuration, check out all the available configurations.

pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven {
name "IMG.LY Artifactory"
url "https://artifactory.img.ly/artifactory/maven"
mavenContent {
includeGroup("ly.img")
}
}
}
}
rootProject.name = "My App"
include ':app'
Navigated to Integrate the Mobile Camera