Effects Android
Effects / Get started / Quickstart / Android

Add real-time camera effects to Android with Nosmai Effects

Updated August 22, 2026

Initialize Nosmai Effects, connect your Camera2 source, show the processed preview, and apply a beauty effect on Android.

Prerequisites

1. Add manifest permissions

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />

2. Initialize Nosmai once

Initialize from the application owner after loading the app-specific key:

NosmaiSDK.initialize(
    getApplicationContext(),
    BuildConfig.NOSMAI_LICENSE_KEY
);

Do not initialize from every activity or fragment. Continue only after camera permission is granted.

3. Add the preview

Add a container to the camera screen:

<FrameLayout
    android:id="@+id/preview_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

Create one NosmaiPreviewView for that container and enable OES input:

FrameLayout container = findViewById(R.id.preview_container);
NosmaiPreviewView previewView = new NosmaiPreviewView(this);

container.addView(previewView);
previewView.enableOesInput(true);

4. Connect the Camera2 source

The Android SDK accepts Camera2 frames from the host application. Connect the front-camera capture session to the OES texture supplied by the preview:

NosmaiPreviewView.OnOesReadyListener oesReady = surfaceTexture -> {
    camera2Source.openFrontCamera(surfaceTexture);
};
previewView.addOnOesReadyListener(oesReady);

Use the public NosmaiPreviewView.OnOesReadyListener type explicitly. This selects the public overload without an ambiguous Java lambda or an internal listener import.

camera2Source is the application's Camera2 owner. It must select a preview size, set sensor orientation, start one repeating capture request, and close the camera when the screen pauses. Reuse an existing camera component when the app already has one. Keep the Nosmai and regular camera sessions from owning the device at the same time.

5. Apply the first effect

Register beauty setup before starting processing. It runs after the pipeline is ready:

previewView.addOnPipelineReady(() -> {
    NosmaiBeauty.applySkinSmoothing(0.4f);
});
NosmaiSDK.startProcessing(previewView);

6. Release the camera

Close the Camera2 session before pausing the preview. Stop Nosmai processing when the camera screen is destroyed:

@Override
protected void onPause() {
    camera2Source.close();
    previewView.onPause();
    super.onPause();
}

@Override
protected void onDestroy() {
    NosmaiSDK.stopProcessing();
    super.onDestroy();
}

Call previewView.onResume() from the matching Activity or Fragment resume callback. The app's Camera2 owner must also reopen its capture session against the current valid OES surface; resuming the view alone does not reopen a camera that the app closed. Serialize close and reopen operations and ignore readiness callbacks for a camera screen that has already been disposed.

Run the screen on a physical arm64-v8a or armeabi-v7a device. The full application structure, Camera2 helper, orientation handling, and OES fallback are demonstrated in the Android WebRTC example. For external-frame setup and orientation, follow the custom frame pipeline guide.

Verify it worked

You should see the front-camera preview and a visible smoothing change at level 0.4. Any on-screen status label is part of your application's UI, not created by these snippets. Move the app to the background and confirm the camera indicator turns off. Return and confirm the same preview resumes.

Common errors

ErrorCauseFix
License key cannot be null or emptyAndroid received an empty keySupply an app-bound key before calling NosmaiSDK.initialize
Preview view cannot be nullstartProcessing was called without a preview instanceCreate NosmaiPreviewView and pass that instance
Nosmai SDK is not initialized. Call NosmaiSDK.initialize() first.Processing started before initializationInitialize once before calling startProcessing
Camera device error: 2Camera2 reported ERROR_CAMERA_IN_USE, usually because another controller still owns the cameraStop and dispose the other camera before opening Nosmai
INSTALL_FAILED_NO_MATCHING_ABISDevice lacks both supported ABIsUse a physical Android device with arm64-v8a or armeabi-v7a

Next steps

References

Nosmai

An AR and AI company. Founded on the idea that the next decade of software will be visual, and that the tools for it should be within reach of anyone building.

Newsletter

Product updates and release notes. No spam.

© 2026 nosmai, inc · all rights reserved