Menu

Building StareBrain, Part 19: Voice Input While Another App Is in the Foreground
πŸ“°

Building StareBrain, Part 19: Voice Input While Another App Is in the Foreground

DEV Community: androidΒ·StareBrainΒ·8 days ago
#tTqojTLC
#devtoandroid#devto#dev#context#speechrecognizer
Reading 0:00
15s threshold

Building StareBrain, Part 19: Voice Input While Another App Is in the Foreground

Parts 16–18 covered the overlay UI: how it appears, how users reposition it, and how it collapses when they're actively using another app. Today we add voice input.

The core constraint: StareBrain should accept a spoken instruction while the user is in a completely different app β€” without requiring them to switch back to StareBrain first.

The Trigger: Floating Mic Button

The overlay already floats above every app. We add a small mic button to its collapsed state. Tapping it starts a voice session without leaving whatever app the user is in.

class OverlayView ( context : Context ) : FrameLayout ( context ) {

var onMicTapped : (() -> Unit )? = null

private val micButton : ImageButton = ImageButton ( context ). apply { setImageResource ( R . drawable . ic_mic ) setOnClickListener { onMicTapped ?.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.