Qt Android Activity View
This module provides a C++ and a QML wrapper for the native ActivityView class. A Qt Quick plugin is provided to enable access using QML.
Android's ActivityView is a handy class for displaying Android's Activity inside another Activity. It provides proper rendering and events handling of the embedded app or activity out of the box. It creates the possibility for embedding one app into another. Such as, displaying a map app and a music player at the same time inside your app.
Using a Qt module requires linking against the module library, either directly or through other dependencies.
Use the find_package() and target_link_libraries() commands to locate and link the needed module component from the Qt6 package:
find_package(Qt6 COMPONENTS AndroidActivityView) target_link_libraries(mytarget PUBLIC Qt::AndroidActivityView)
androidactivityview to the
QT += androidactivityview
To include the definitions of the module's classes, use the following directive for C++:
For the QML types add the following import statement to your .qml file:
Links to the API reference materials:
Only Android 10 and 11 are supported.
An ActivityView component is always rendered on top. It can be freely changed in size and position. However, the standard z-order rules do not apply. It is always rendered above all components rendered by QML. Additionally, it is also not possible to apply transformations such as rotation or scaling, changing the opacity or offscreen rendering using layers.
The Activity resolved by the provided
className must have the resizeableActivity attribute set to
true in order to be launched correctly as an embedded activity. Also, if the activity is not owned by the owner of this app, it must allow embedding. This rule also applies to activities launched from within embedded activities. Otherwise, new activities may not behave correctly, e.g. be launched in full screen.
In case of Android 11 platform only one ActivityView can get touch events at a time. When working with multiple ActivityViews, the user will have to make an 'initial tap' on the activity to give it focus for receiving touch events.
When an activity is running in ActivityView, an attempt to run the same activity with Context.startActivity() may not show the activity on the screen. To overcome this problem, use the two parameter version of this function, so you can specify the displayId for the activity to show up.
Note: Because of this ActivityView should not be considered a general-purpose API. Apps to be embedded should be written with this criteria taken in mind. In the case of external apps, they should be thoroughly tested, especially in terms of starting new activities.
Available under certain Qt licenses.
Find out more.