Skip to content

2.2 Special APIs for Android for Layout Management

In Android, it is recommended to store the NIMMSTA Layout XML files inside the res/raw folder. Therefore, we provide some APIs in order to set these layouts as well:

class ExampleActivity : NIMMSTAEventHandler {
    /* ... */

    override fun didConnectAndInit(device: NIMMSTADevice) {
        device.setLayout(R.raw.nimmsta_layout_first)
        // if you want to set or override the variables defined in the layout you can do so here
        device.setLayout(R.raw.nimmsta_layout_first, mapOf(
            "variable1" to "foo"
        ))
    }
}

```Java class ExampleDelegate implements NIMMSTADeviceDelegate { / ... /

    @Override
    public void didConnectAndInit(NIMMSTADevice nimmstaDevice) {
        NIMMSTADeviceExtension.setLayout(nimmstaDevice, R.raw.nimmsta_layout_first);
        // if you want to set or override the variables defined in the layout you can do so here
        HashMap<String, String> map = new HashMap<String, String>();  
        map.put("title", "new title");
        NIMMSTADeviceExtension.setLayout(nimmstaDevice, R.raw.nimmsta_layout_first, map);
    }

    /* ... */
}
```