QAndroidIntent Class

封装 Android Intent 类最重要的方法。更多

头文件: #include <QtCore/private/qandroidextras_p.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
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 extras 返回额外的key 数据

QVariant QAndroidIntent::extraVariant(const QString &key)

从 Intent extras 返回额外的key 数据,作为一个QVariant

QJniObject QAndroidIntent::handle() const

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

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

在 Intent extras 中使用data 设置key

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

使用 Intent extras 中的value 设置key

© 2025 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.