- Overview
- Creating an Android Widget window
- Characteristics of an Android widget window
- Size of a Widget window
- Update the content
- Redisplaying the Widget window
- Widget image
- Programming an Android widget window
- Opening a Widget window
- Closing a Widget window
An Android application can contain one or more Widget windows. These windows can be displayed on a tablet or phone's home screen. The information displayed in these windows is updated on a regular basis. Widget windows allow simple interactions with the user. Creating an Android Widget window To create an Android Widget window: - Click
in the quick access buttons: - The new element window appears: click "Window" then "Window".
- The window creation wizard starts.
- In the "Standard" tab, in the "Other platform" area, select "Blank for widget" and validate.
- A new window is created in the editor. Only 3 types of controls are available in Widget windows: Button controls, Static controls and Image controls.
Caution: The styles defined for the controls of a widget in edit mode will be ignored at runtime. You can only set the background color of the controls and the background image of Button controls.
Remark: You can also change the type of an existing window: - Open the window description (select "Description" in the context menu).
- In the "UI" tab, select "Widget (Android/iOS14+)".
- Validate.
Characteristics of an Android widget window Size of a Widget window The size of a Widget window is defined in number of vertical and horizontal cells. This size can be configured in the "UI" tab of the description window: The size of a cell is set to 74 pixels for the side (for a dpi of 160). For a display compatible with most of the devices (phones and tablets), the maximum size should not exceed 4 x 4 cells. Remark: Widgets created with WINDEV Mobile cannot be resized. Update the content Widget windows include a specific event: Refreshing the widget. This event is used to update the widget content. This event starts at regular time intervals. The refresh frequency is defined in the "UI" tab of the description window. Remarks: - This refresh frequency cannot be less than 30 minutes.
- WidgetDisplay redisplays the widget and runs the "Refresh widget" event.
Redisplaying the Widget window A widget window is displayed by the process that manages the device's home screen. This display is not always performed. It is updated in the following cases: - Adding a new instance of the widget on the home screen.
- Once a widget button or image was clicked.
- After updating the content of the widget.
Remark: WidgetDisplay redisplays the widget and runs the "Refresh widget" event. Widget image When installing a widget on the desktop, the user can see the list of widgets on their computer. This list contains, for each widget, the widget name and the preview image. The widget preview image is defined in the "UI" tab of the description window. You can: - provide a specific image.
- genereate a screenshot of the window. In this case, the screenshot is automatically associated with the preview image.
If no image is specified, the icon of the Android application will be automatically used. Programming an Android widget window Opening a Widget window You cannot explicitly request the opening of a Widget window. The opening functions ( OpenSister, OpenChild, Use) will trigger a fatal error if they are used in widget mode. Widget windows are automatically opened in the following cases: - Adding the first instance of the widget that corresponds to the window on the home screen.
- After starting the device if at least one instance of the widget is present on the home screen.
- When updating the widget or when the user interacts with the widget (click on a button for example).
- If the process was stopped by the system (if it needs resources for example).
The events run when a Widget window is open are: - "Global declarations" of the window.
- "Initializing" window controls.
- "Initializing" the window.
- "Refresh widget".
The "Initializing" event associated with the project will only be run before the first Widget window of the application is opened. To differentiate the widget-specific code from the application-specific code in this event, use InWidgetMode. Closing a Widget window You cannot explicitly request the closing of a Widget window. Close will trigger a fatal error if it is used in widget mode. Widget windows are automatically closed when the last instance of the widget is removed from the home screen. The "Close" event (associated with the window) is run when a Widget window is closed. The "Close" event associated with the project will be executed when the last instance of an application widget is removed from the Home screen and there are no more instances of other widgets displayed.
|
|
|
|