本页内容

QAndroidIntent Class

封装了 Android Intent 类中最重要的一些方法。更多内容...

头文件: #include <QtCore/private/qandroidextras_p.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS CorePrivate)
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
qmake: QT += core-private
自: Qt 6.2
状态: 技术预览

该类处于技术预览阶段,内容可能会有变动。

公共函数

QAndroidIntent()
QAndroidIntent(const QJniObject &intent)
QAndroidIntent(const QString &action)
QAndroidIntent(const QJniObject &packageContext, const char *className)
QByteArray extraBytes(const QString &key)
QVariant extraVariant(const QString &key)
QJniObject handle() const
void putExtra(const QString &key, const QByteArray &data)
void putExtra(const QString &key, const QVariant &value)

详细说明

QAndroidIntent 是一个便利类,封装了最重要的Android Intent方法。

成员函数文档

QAndroidIntent::QAndroidIntent()

创建一个新的意图

[explicit] QAndroidIntent::QAndroidIntent(const QJniObject &intent)

封装了提供的intent Java对象。

[explicit] QAndroidIntent::QAndroidIntent(const QString &action)

创建一个新的意图,并设置所提供的action 。

[explicit] QAndroidIntent::QAndroidIntent(const QJniObject &packageContext, const char *className)

创建一个新的意图,并设置提供的packageContext 和className 服务。示例:

auto serviceIntent = QAndroidIntent(QtAndroidPrivate::androidActivity().object(), "com.example.MyService");

另请参阅 QtAndroidPrivate::bindService 。

QByteArray QAndroidIntent::extraBytes(const QString &key)

从 Intent 附加数据中返回额外的key 数据

QVariant QAndroidIntent::extraVariant(const QString &key)

将 Intent 附加数据中的额外key 数据作为QVariant

QJniObject QAndroidIntent::handle() const

该返回值可用于调用本封装类未涵盖的其他 Java API

void QAndroidIntent::putExtra(const QString &key, const QByteArray &data)

通过 Intent 的额外参数(extras)将key 设置为data

void QAndroidIntent::putExtra(const QString &key, const QVariant &value)

通过 Intent 附加信息中的value 设置key 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.