Skip to main content

Module background

Module background 

Source
Expand description

Background execution: ask the OS to keep running briefly after the app is backgrounded, so in-flight work (e.g. draining a recognition queue) can finish instead of being suspended immediately.

The platform backend installs an implementation via set_platform_background_activity (iOS beginBackgroundTask, Android a foreground service). No default: background_activity returns None where unsupported, and the app simply runs only while foregrounded.

Traits§

BackgroundActivity
Marks periods of important work so the platform grants background running time. Implementations are Send + Sync (the app toggles activity from its worker threads).

Functions§

background_activity
The registered background-activity handler, or None where unsupported.
clear_platform_background_activity
Removes any registered handler (tests/teardown).
set_background_active
Convenience: mark background work active/inactive (no-op where unsupported).
set_platform_background_activity
Installs the platform background-activity handler, replacing any previous one.

Type Aliases§

BackgroundActivityRef