C

Embedded Clock and Contacts Apps

An app that embeds the Clock and Contacts apps in floating window using the Qt for Android Automotive ActivityView type.

"ActivityView Dialogs Example Screenshot"

Building and deploying the example

See specific steps relating to building and deploying Qt for Android Automotive examples.

Including the API

To use the ActivityView plugin in Qt Quick application, first, we have to import the Qt for Android Automotive ActivityView module in QML:

import QtAndroidAutomotive.ActivityView

Wrapping an application inside the floating window

In the example, we implement a floating window QML type by using a draggable rectangle. This type is defined in FloatingWindow.qml and it encapsulates the visual appearance and behavior.

Next, in Main.qml, we will declare a floating window component, ActivityViewWindow, based on FloatingWindow.

    component ActivityViewWindow: FloatingWindow {
        id: activityViewWindow

Using ActivityView

The ActivityView QML API related functionality is covered by the ActivityView item placed inside ActivityViewWindow, and by setting parameters of each embedded Activity.

        ActivityView {
            id: activityView

            anchors.fill: parent
            anchors.margins: applicationWindow.activityMargin

            radius: 25

            usePlaceholder: activityViewWindow.resizing || activityViewWindow.moving

            placeholder: Text {
                id: activitySymbol
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
                font.pixelSize: 64
            }

            BusyIndicator {
                anchors.centerIn: parent

                visible: activityView.status !== ActivityView.Status.Started
            }
        }

With the ActivityViewWindow component we can now define two floating windows, which will wrap the Activities of Android Applications. In this example we are embedding the Clock and Contacts applications inside these two windows.

    ActivityViewWindow {
        id: firstWindow

        title: "Clock"
        packageName: "com.android.deskclock"
        symbol: "🕑"
        visible: false
    }

    ActivityViewWindow {
        id: secondWindow

        title: "Contacts"
        packageName: "com.android.contacts"
        symbol: "👤"
        visible: false
    }

Available under certain Qt licenses.
Find out more.