- ProGlove documentation
- MAI
- MAI integration
- Screen related events
Screen related events
Screen Events
Screen events provide essential runtime feedback about user interactions with the screen as well as automatic screen-related actions. They enable the creation of dynamic, interactive, and responsive workflows.Each event includes detailed screen context, capturing exactly what was shown on the screen at the moment the event occurred. This allows accurate interpretation of events by understanding the structure and content of the screen—even in multi-view or input-driven workflows.
Receive the Screen Events
Screen events are emitted in real time and integrator can receive them through any integration path except Keyboard.
SDK
Screen events are received by subscribing to display events. Subscribe by calling pgManager.subscribeToDisplayEvents() with your IDisplayOutput implementation. Override the callback methods of interest. The onScreenEvent() callback is triggered when a certain screen event is was triggered.Note: Subscribing to display events, you will subscribing to display connection state as well. When implementing IDisplayOutput, make sure to explicitly override onScreenEvent(), since it has an empty default implementation by default.Important: Make sure you unsubscribe from display events once you don’t need them anymore to prevent memory leaks, e.g. inside the onDestroy or onClear callback functions.
Notice
Note: Subscribing to display events, you will subscribing to display connection state as well. When implementing IDisplayOutput, make sure to explicitly override onScreenEvent(), since it has an empty default implementation by default.
Important
Important: Make sure you unsubscribe from display events once you don’t need them anymore to prevent memory leaks, e.g. inside the onDestroy or onClear callback functions.
Code (SDK)
//...
val displayOutput = object : IDisplayOutput {
  
    override fun onDisplayConnected() {
        // Inform the user that display device has been connected
        // Check which display type does connected device has (e.g. MAI has dislpay v2)
    }
    
    override fun onDisplayDisconnected() {
        // Inform the user that the display device has been disconnected
    }
  
    fun onScreenEvent(screenEvent: PgScreenEvent) {
        // Handle screen events
        handleScreenEvents(screenEvent)
    }
}
override fun onCreate(savedInstanceState: Bundle?) {
     //...
     pgManager.subscribeToDisplayEvents(displayOutput)
     
     //...
}
override fun onDestroy() {
    super.onDestroy()
    pgManager.unsubscribeFromDisplayEvents(displayOutput)
    
    //...
}
private fun handleScreenEvents(screenEvent: PgScreenEvent) {
    when (screenEvent) {
        is PgScreenEvent.ScreenComponentClicked -> {
            // Handle component clicked event, using
            // clicked component reference ID and screen context
        }
        is PgScreenEvent.ScreenDataUpdated -> {
            // Handle screen data updated event, using
            // reference ID of the component which content was changed and screen context
        }
        is PgScreenEvent.ScreenTimerExpired -> {
            // Handle screen timer expired event, using screen context
        }
    }
}
     
//...Intent
Integrator can listen for display screen events by registering BroadcastReceiver that should be triggered by the implicit Intent with action: com.proglove.api.DISPLAY_SCREEN_EVENT. For extras and other Intent specification details.
Screen Event Types
There are three types of screen events that can be emitted when interacting with a screen.
Screen Component Clicked
Triggered when a user taps a clickable screen component (such as a button or a list item) with assigned Notify action.
Event parameters:
- componentId: reference ID of the clicked component
- screenContext: current screen state at the time of click
Usage:
This is typically used for leveraging the user input for building the efficient workflows.
Note
Note: Text Fields do not trigger this events on click, but when there is a InputMethod assigned to it, input widget will appear. After content input is done and confirmed, ScreenDataUpdated screen event will be triggered.
Screen Data Updated
Triggered after the content of a component has been modified by the user on the device, e.g. after text field’s data has been updated using the input widget (assigned through the InputMethod).
Event parameters:
- componentId: reference ID of the component which content was updated
- screenContext: current screen state reflecting the updated data
Usage:
This is typically used to collect user-entered input. Use the componentId to identify which field changed, and to retrieve its content from the screenContext.
Screen Timer Expired
Triggered when a screen timer with Notify action (set via PgScreenTimer.Enabled) reaches its timeout.
Event parameters:
- screenContext: screen state at the moment the timer expired
Usage:
This can be used to implement passive workflows, auto-dismiss behaviors, or trigger transitions after a delay.
Note
Note: This will be triggered only if timer has action set to Notify