C

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 the Module

Using a Qt module requires linking against the module library, either directly or through other dependencies.

Building with CMake

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)

Building with qmake

Add androidactivityview to the QT variable:

QT += androidactivityview

C++ API

To include the definitions of the module's classes, use the following directive for C++:

#include <QtAndroidActivityView>

QML API

For the QML types add the following import statement to your .qml file:

import QtAndroidAutomotive.ActivityView

API Reference

Links to the API reference materials:

Examples

Activity View Known issues and limitations

Only Android 10, 11 and 12 are supported.

Since ActivityView relies on private Android APIs, apps that use it must be signed with a platform key.

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 packageName and 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 fullscreen.

Android 10 and 11

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.

Android 12

Due to the limitations in the underlying Android 12 API, only one app can successfully use ActivityViews for embedding other apps. If another app with ActivityView is launched, the previously launched app's activity embedding may not work as expected anymore.

When an Activity has been embedded into an ActivityView in Android 12, trying to start the same Activity outside of it, in fullscreen mode, may not show the Activity on the screen. If you want to start the embedded Activity in fullscreen, you need to remove it from the ActivityView first by clearing its packageName.

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.