Android
To test your code and see a preview of the card on an Android device, use the DivKit Playground app. You can add the card code in JSON format to the app or open a link to it:
-
Install the DivKit Playground app.
-
Select demo.
-
Add a card using one of the following methods:
- Insert the code in JSON format or a link to the card prototype in the input field.
- Open the link from the DivKit Web Playground editor.
- Select the file in JSON format on the device.
Tip
To create a card code, you can use the DivKit Web Playground sample library.
-
To view the result, click show the result.
Data state management
DivKit for Android provides an API for managing stored data. You can reset cached variables and DivData using the reset() function.
Resetting data
// Reset all stored data
divKitComponent.reset()
// Reset only stored variables
divKitComponent.reset(DivKit.RESET_STORED_VARIABLES)
// Reset only stored DivData
divKitComponent.reset(DivKit.RESET_STORED_DIV_DATA)
// Reset data with tag filtering
divKitComponent.reset(
flags = DivKit.RESET_STORED_VARIABLES,
tags = listOf("tag1", "tag2")
)
// Reset DivData with tag filtering
divKitComponent.reset(
flags = DivKit.RESET_STORED_DIV_DATA,
tags = listOf("tag1", "tag2")
)
// Combined reset with tag filtering
divKitComponent.reset(
flags = DivKit.RESET_STORED_VARIABLES or DivKit.RESET_STORED_DIV_DATA,
tags = listOf("tag1", "tag2")
)
Reset flags:
RESET_ALL- reset all data (used by default)RESET_STORED_VARIABLES- reset only stored variablesRESET_STORED_DIV_DATA- reset only stored DivData
Flags can be combined using bitwise OR:
divKitComponent.reset(DivKit.RESET_STORED_VARIABLES or DivKit.RESET_STORED_DIV_DATA)
Note
The reset() method now supports selective reset of stored values for specific card tags. This allows precise data state management without global reset.
Access to storage component
For advanced data management, the storage component is available:
val storageComponent = divKitComponent.storageComponent
View the result on a remote device
The DivView internal service for viewing HTML card previews is available for Yandex staff employees. With DivView, you can display a card preview remotely on an Android mobile device from Yandex Kolhoz:
-
Go to DivView.
-
In the input field, insert the code of the card prototype in JSON format.
Tip
To use ready-made samples, in the upper right part of the page, click Samples and select an item from the library. You can edit and refine the samples.
-
Click + Android Kolhoz. If you haven't worked in Yandex Kolhoz yet, confirm logging in in the window that appears.
Learn more about Yandex Kolhoz. -
The Android device available to you will be automatically booked for 1 hour. Its name will be displayed in DivView next to the + Android Kolhoz button.
-
The card preview will be displayed in DivView in the center of the page. During the demonstration, the preview will also be displayed on the device in Yandex Kolhoz.
-
The card structure is displayed in DivView on the right side of the page. If there are errors in the code, they will be displayed in the Errors section under the card preview.
Learn more
You can discuss topics of interest in the DivKit user community in Telegram: https://t.me/divkit_community_en.