QtAndroidPrivate Namespace

The QtAndroidPrivate namespace provides miscellaneous functions to aid Android development. More...

Header: #include <QtCore/private/qandroidextras_p.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
qmake: QT += core-private
Since: Qt 6.2
Status: Preliminary

This namespace is under development and is subject to change.

Types

(since 6.2) enum class BindFlag { None, AutoCreate, DebugUnbind, NotForeground, AboveClient, …, ExternalService }
flags BindFlags

Functions

(since 6.2) bool bindService(const QAndroidIntent &serviceIntent, const QAndroidServiceConnection &serviceConnection, QtAndroidPrivate::BindFlags flags = BindFlag::None)
(preliminary) QFuture<QtAndroidPrivate::PermissionResult> checkPermission(const QString &permission)
(preliminary) QFuture<QtAndroidPrivate::PermissionResult> requestPermission(const QString &permission)
(since 6.2) void startActivity(const QAndroidIntent &intent, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)
(since 6.2) void startActivity(const QJniObject &intent, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)
(since 6.2) void startActivity(const QJniObject &intent, int receiverRequestCode, std::function<void (int, int, const QJniObject &)> callbackFunc)
(since 6.2) void startIntentSender(const QJniObject &intentSender, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)

Detailed Description

Type Documentation

[since 6.2] enum class QtAndroidPrivate::BindFlag
flags QtAndroidPrivate::BindFlags

This enum is used with QtAndroidPrivate::bindService to describe the mode in which the binding is performed.

ConstantValueDescription
QtAndroidPrivate::BindFlag::None0x00000000No options.
QtAndroidPrivate::BindFlag::AutoCreate0x00000001Automatically creates the service as long as the binding exist. See BIND_AUTO_CREATE documentation for more details.
QtAndroidPrivate::BindFlag::DebugUnbind0x00000002Include debugging help for mismatched calls to unbind. See BIND_DEBUG_UNBIND documentation for more details.
QtAndroidPrivate::BindFlag::NotForeground0x00000004Don't allow this binding to raise the target service's process to the foreground scheduling priority. See BIND_NOT_FOREGROUND documentation for more details.
QtAndroidPrivate::BindFlag::AboveClient0x00000008Indicates that the client application binding to this service considers the service to be more important than the app itself. See BIND_ABOVE_CLIENT documentation for more details.
QtAndroidPrivate::BindFlag::AllowOomManagement0x00000010Allow the process hosting the bound service to go through its normal memory management. See BIND_ALLOW_OOM_MANAGEMENT documentation for more details.
QtAndroidPrivate::BindFlag::WaivePriority0x00000020Don't impact the scheduling or memory management priority of the target service's hosting process. See BIND_WAIVE_PRIORITY documentation for more details.
QtAndroidPrivate::BindFlag::Important0x00000040This service is assigned a higher priority so that it is available to the client when needed. See BIND_IMPORTANT documentation for more details.
QtAndroidPrivate::BindFlag::AdjustWithActivity0x00000080If binding from an activity, allow the target service's process importance to be raised based on whether the activity is visible to the user. See BIND_ADJUST_WITH_ACTIVITY documentation for more details.
QtAndroidPrivate::BindFlag::ExternalService-2147483648The service being bound is an isolated, external service. See BIND_EXTERNAL_SERVICE documentation for more details.

This enum was introduced in Qt 6.2.

The BindFlags type is a typedef for QFlags<BindFlag>. It stores an OR combination of BindFlag values.

Function Documentation

[since 6.2] bool QtAndroidPrivate::bindService(const QAndroidIntent &serviceIntent, const QAndroidServiceConnection &serviceConnection, QtAndroidPrivate::BindFlags flags = BindFlag::None)

Binds the service given by serviceIntent, serviceConnection and flags. The serviceIntent object identifies the service to connect to. The serviceConnection is a listener that receives the information as the service is started and stopped.

Returns true on success

See Android documentation documentation for more details.

This function was introduced in Qt 6.2.

See also QAndroidIntent, QAndroidServiceConnection, and BindFlag.

[preliminary] QFuture<QtAndroidPrivate::PermissionResult> QtAndroidPrivate::checkPermission(const QString &permission)

This function is under development and is subject to change.

Checks whether this process has the named permission and returns a QFuture representing the result of the check.

This function was introduced in Qt 6.2.

See also requestPermission().

[preliminary] QFuture<QtAndroidPrivate::PermissionResult> QtAndroidPrivate::requestPermission(const QString &permission)

This function is under development and is subject to change.

Requests the permission and returns a QFuture representing the result of the request.

This function was introduced in Qt 6.2.

See also checkPermission().

[since 6.2] void QtAndroidPrivate::startActivity(const QAndroidIntent &intent, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)

Starts the activity given by intent and provides the result asynchronously through the resultReceiver if this is non-null.

If resultReceiver is null, then the startActivity() method of QNativeInterface::QAndroidApplication::context() will be called. Otherwise startActivityForResult() will be called.

The receiverRequestCode is a request code unique to the resultReceiver, and will be returned along with the result, making it possible to use the same receiver for more than one intent.

This function was introduced in Qt 6.2.

[since 6.2] void QtAndroidPrivate::startActivity(const QJniObject &intent, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)

Starts the activity given by intent and provides the result asynchronously through the resultReceiver if this is non-null.

If resultReceiver is null, then the startActivity() method of QNativeInterface::QAndroidApplication::context() will be called. Otherwise startActivityForResult() will be called.

The receiverRequestCode is a request code unique to the resultReceiver, and will be returned along with the result, making it possible to use the same receiver for more than one intent.

This function was introduced in Qt 6.2.

[since 6.2] void QtAndroidPrivate::startActivity(const QJniObject &intent, int receiverRequestCode, std::function<void (int, int, const QJniObject &)> callbackFunc)

Starts the activity given by intent, using the request code receiverRequestCode, and provides the result by calling callbackFunc.

This function was introduced in Qt 6.2.

[since 6.2] void QtAndroidPrivate::startIntentSender(const QJniObject &intentSender, int receiverRequestCode, QAndroidActivityResultReceiver *resultReceiver = nullptr)

Starts the activity given by intentSender and provides the result asynchronously through the resultReceiver if this is non-null.

If resultReceiver is null, then the startIntentSender() method of QNativeInterface::QAndroidApplication::context() will be called. Otherwise startIntentSenderForResult() will be called.

The receiverRequestCode is a request code unique to the resultReceiver, and will be returned along with the result, making it possible to use the same receiver for more than one intent.

This function was introduced in Qt 6.2.