Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/RealComputer/GlassKit/llms.txt

Use this file to discover all available pages before exploring further.

The Rokid Feature Demo is a reference Android app for Rokid Glasses that exercises the core device features you’ll reach for in nearly every real app. It covers touchpad and voice-command navigation, live camera preview, microphone level metering, and audio playback — all using reusable ScreenController components you can copy directly. When physical glasses are unavailable, the app runs on a standard Android phone or an AVD emulator with a touchscreen fallback for the Rokid touchpad.

Control Mapping

All interactions map to three input sources. Use the table below as a reference when testing on different hardware.
IntentRokid Glasses touchpad (KeyEvent)Voice commandAndroid touchscreen
Select / OKTap (KEYCODE_ENTER)selectTap
Back / cancelDouble tap (KEYCODE_BACK)backDouble tap
Move focus right/downSwipe forward (KEYCODE_DPAD_DOWN)nextSwipe right
Move focus left/upSwipe back (KEYCODE_DPAD_UP)previousSwipe left
Do not disable the back control on your app’s root screen. On Rokid Glasses the double-tap back is the only way to exit the app.

Setup

1. Download the Vosk Model

Vosk handles offline voice commands. Run the download script before your first build:
./scripts/download_vosk_model.sh

2. Emulator Setup (optional)

If you want to develop without physical glasses, create an AVD with a Rokid-matching screen shape.
1

Install the system image and create the AVD

sdkmanager "system-images;android-36.1;google_apis;arm64-v8a"
avdmanager create avd \
  -n glass_480x640 \
  -k "system-images;android-36.1;google_apis;arm64-v8a" \
  -d "pixel_9a"
2

Configure the AVD for Rokid screen dimensions

Edit ~/.android/avd/glass_480x640.avd/config.ini and add or update these four keys:
hw.lcd.width=480
hw.lcd.height=640
hw.lcd.density=240
hw.audioOutput=yes
3

Launch the emulator

emulator -avd glass_480x640 -camera-back emulated
Other -camera-back sources (webcam0, virtualscene, videoplayback) may work depending on your local setup.
Host microphone passthrough is optionally available: add hw.audioInput=yes to config.ini, start the emulator with -allow-host-audio, then run adb emu avd hostmicon. In practice, camera and microphone passthrough on the emulator are not always stable enough for reliable development testing.

Build and Install

Build a debug APK:
./gradlew :app:assembleDebug
Install to a connected device (or running emulator):
adb install app/build/outputs/apk/debug/app-debug.apk
To stream logs from the running app:
adb logcat -v time --pid "$(adb shell pidof -s com.example.rokidfeaturedemo)"

Architecture

The app uses a ScreenController pattern to keep each screen’s state, rendering, and input handling isolated from the activity shell. MainActivity owns the lifecycle, permissions, and input routing; each screen is a self-contained controller class.
ClassResponsibility
MainActivityActivity shell: shared lifecycle, permissions, Rokid/emulator input mapping, screen navigation.
RokidHudViewportLayoutFixed 3:4 HUD viewport container that keeps phone rendering letterboxed to the Rokid Glasses shape.
ScreenControllerShared screen abstractions and navigation results.
MenuScreenControllerMain menu screen: focus navigation, select action.
AudioScreenControllerAudio test tones: play/stop controls.
CameraScreenControllerLive camera preview.
MicrophoneScreenControllerLive microphone level meter and current voice-command status.
VoiceCommandRecognizerVosk model unpacking, endpoint tuning, AudioRecord loop, partial/final result parsing, and command dispatch.

Screens

The app has four screens you can navigate between using the control mapping above:
  • Menu — root screen with navigation to the three feature screens.
  • Camera — live camera preview rendered on the HUD.
  • Audio — playback test tones to verify speaker output.
  • Microphone — live input level meter plus the current Vosk voice-command recognition status.

Key Files

FileDescription
app/src/main/java/…/MainActivity.ktActivity shell for lifecycle, permissions, input mapping, and screen navigation.
app/src/main/java/…/RokidHudViewportLayout.kt3:4 letterbox container for phone/emulator rendering.
app/src/main/java/…/ScreenController.ktBase screen abstractions and navigation result types.
app/src/main/java/…/MenuScreenController.ktMenu screen state and rendering.
app/src/main/java/…/CameraScreenController.ktCamera preview screen.
app/src/main/java/…/AudioScreenController.ktAudio test tone screen.
app/src/main/java/…/MicrophoneScreenController.ktMicrophone level meter and Vosk status screen.
app/src/main/java/…/VoiceCommandRecognizer.ktVosk model loading, AudioRecord loop, and command dispatch.
app/src/main/res/layout/activity_main.xmlShared HUD chrome with per-screen layout includes.
scripts/download_vosk_model.shDownloads the Vosk ASR model into the project assets.

Build docs developers (and LLMs) love