LeiaSR SDK provides means of supporting LeiaSR devices. It provides a simple API to setup and use all necessary components.
While not absolutely required, the LeiaSR SDK will allow you to harness the ability of your LeiaSR device in a simple manner. Any developer attempting to create LeiaSR 3D experiences without LeiaSR SDK will encounter significant technical challenges. We therefore highly suggest using LeiaSR SDK for your application.
Let’s start from a quick example.
Initialize LeiaSR SDK
class MainApp : Application() {
override fun onCreate() {
// ...
val initArgs = LeiaSDK.InitArgs()
initArgs.platform.app = this
LeiaSDK.createSDK(initArgs)
}
}
Add InterlacedSurfaceView to a layout
<androidx.constraintlayout.widget.ConstraintLayout
...>
<com.leia.sdk.views.InterlacedSurfaceView
android:id="@+id/interlacedView"
... />
</androidx.constraintlayout.widget.ConstraintLayout>
Set InterlacedSurfaceView content
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
// ...
val bitmap = ... // Load Bitmap
val asset = InputViewsAsset.createSurfaceFromLoadedBitmap(bitmap, true)
val interlacedView = findViewById(R.id.interlacedView)
interlacedView.setViewAsset(asset)
}
}
Enable the Backlight
class MainActivity : AppCompatActivity() {
override fun onWindowFocusChanged(hasFocus: Boolean) {
// ...
LeiaSDK.getInstance()?.let {
it.enable3D(hasFocus)
it.startFaceTracking(hasFocus)
}
}
}
And that’s it.
For more, see samples provided with LeiaSR SDK. Also, make sure to read documentation of the main classes: LeiaSDK, InterlacedSurfaceView, InputViewsAsset.
ProGuard (Obfuscation)
LeiaSR SDK contains native components that are calling into Java components using Java Native Interface. Because of that ProGuard obfuscation/optimization should not be applied to LeiaSR SDK Java bytecode. The following ProGuard rules can be used to achieve this:
-keep class com.leia.sdk.** { *; }
-keep class com.leia.core.** { *; }
-keep class com.leia.internal.** { *; }
-keep class com.leia.headtracking.** { *; }
It’s better to use the provided rules instead of using -keep class com.leia.** { *; }
because it will disable optimization for other Leia libraries which in
the general case is undesirable.
Shared Library Loading
LeiaSR SDK contains native components that are loaded dynamically in runtime thus
the resulting apk should be aware of it. In order for LeiaSR SDK to properly
load its native libraries, an app must either be configured with useLegacyPackaging=false
(default) or if it requires useLegacyPackaging=true
then it
should have android:extractNativeLibs="true"
in its AndroidManifest.xml.