C
AndroidAppsUtils QML Type
Qt wrapper for Android Apps Utils. More...
Import Statement: | import QtAndroidAutomotive.Base |
Properties
- installedAppsModel : model
Methods
- int appUid(string packageName)
(since QtAndroidAutomotive 6.5)
- bool hasNotificationAccess(string notificationListenerServiceName)
- bool showAppInfo(string packageName)
- bool startActivityWithAction(string action)
- bool startApp(string packageName)
- bool startAppOnScreen(string packageName, const QQuickScreenInfo *screenInfo)
(since QtAndroidAutomotive 6.5)
- bool startAppOnScreenById(string packageName, int displayId)
(since QtAndroidAutomotive 6.5)
- bool uninstallApp(string packageName)
Detailed Description
AndroidAppsUtils
allows access to Android APIs to work with apps such as starting, uninstalling, and fetching names and icons.
Property Documentation
installedAppsModel : model |
This property holds the model for installed apps on an Android device. The model is based on a QAbstractListModel and manages a list of elements containing the app name, package name and icon that are retrieved from the Android Drawable counterpart.
Below is a snippet for using this model:
ListView { id: listView clip: true flickableDirection: Flickable.VerticalFlick model: AndroidAppsUtils.installedAppsModel delegate: Rectangle { id: delegate height: window.height * 0.05 width: ListView.view.width Row { Text { id: appName text: model.appName + " " + model.packageName } } } }
To use an app's icon in an Image, use the following:
Image { id: appIcon source: model.AppIconString }
Method Documentation
Returns the UID for the package specified by packageName or -1
if specified package cannot be found.
Button { id: uidButton onClicked: { const uid = AndroidAppsUtils.appUid("org.qtproject.example.name") console.log("User ID:", uid) } }
This method was introduced in QtAndroidAutomotive 6.5.
Checks whether the Notification Listener Service, notificationListenerServiceName has notification access. Returns true
if the access is granted, false
otherwise.
The notificationListenerServiceName needs to be the full name of your notification listener service class that you defined in the AndroidManifest file. For more information, see Android: NotificationListenerService.
The notification access needs to be granted by the user from the notification access settings view. To open that view, you can do the following:
Component.onCompleted: { if (!AndroidAppsUtils.hasNotificationAccess("com.example.mynotificationlistenerservice")) { AndroidAppsUtils.startActivityWithAction( "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS") } }
See also AndroidAppsUtils::startActivityWithAction(string action).
Shows the info settings view for the app associated with the provided packageName. Returns true
if the app Activity is found and stated, false
if not found.
Button { id: startButton onClicked: AndroidAppsUtils.showAppInfo("org.qtproject.example.name") }
Starts the activity associated to a given action. For more information, see Android: Building an Intent. Returns true
if the app Activity is found and started, false
otherwise.
For example, to open the Bluetooth settings view, you can use the following code:
Button { id: startButton text: qsTr("Open Bluetooth Settings") onClicked: AndroidAppsUtils.startActivityWithAction("android.settings.BLUETOOTH_SETTINGS") }
Starts the app associated with the provided packageName. Returns true
if the app Activity is found and stated, false
if not found.
Button { id: startButton onClicked: AndroidAppsUtils.startApp("org.qtproject.example.name") }
Starts the app associated with the provided packageName on screen identified with screenInfo.
Returns true
if the application was started, false
otherwise.
Button { id: startButton onClicked: AndroidAppsUtils.startAppOnScreen("org.qtproject.example.name", Application.screens[0]) }
This method was introduced in QtAndroidAutomotive 6.5.
See also Application.screens.
Starts the app associated with the provided packageName on screen identified with displayId.
Returns true
if the application was launched, false
otherwise.
Button { id: startButton onClicked: AndroidAppsUtils.startAppOnScreenById("org.qtproject.example.name", 0) }
This method was introduced in QtAndroidAutomotive 6.5.
See also Application.screens.
Requests the uninstall dialog for the app associated with the provided packageName. Returns true
if the app Activity is found and stated, false
if not found.
Button { id: startButton onClicked: AndroidAppsUtils.uninstallApp("org.qtproject.example.name") }
Available under certain Qt licenses.
Find out more.