Device API
Handles TV-related operations, such as rebooting, shutting down, and resetting to factory conditions.
device.foregroundApp
Signatures
foregroundApp()
Description
Queries the device for the app currently running on it.
Returns a Lua-friendly map with app_id, app_version, and app_name
fields. app_version and app_name may be nil if the protocol can't
cheaply report them.
If the live query fails (e.g. the platform does not expose the running app),
falls back to the app stored in the automation context from launch time. If
neither is available, all fields are returned as nil so automations can
handle the case gracefully.
local info = device.foregroundApp() print(info.app_id, info.app_version, info.app_name)