QAndroidIntent Class

Wraps the most important methods of Android Intent class. 更多...

头: #include <QtCore/private/qandroidextras_p.h>
qmake: QT += core-private
Since: Qt 6.2
Status: Preliminary

该类在开发且可能改变。

公共函数

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 )

详细描述

The QAndroidIntent is a convenience class that wraps the most important Android Intent 方法。

When building with CMake, use the following commands to use private Qt Core APIs:

find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::CorePrivate)
					

成员函数文档编制

QAndroidIntent:: QAndroidIntent ()

Create a new intent

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

Wraps the provided intent java object.

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

Creates a new intent and sets the provided action .

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

Creates a new intent and sets the provided packageContext and the service className 。范例:

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

另请参阅 QtAndroidPrivate::bindService .

QByteArray QAndroidIntent:: extraBytes (const QString & key )

Returns the extra key data from the Intent extras

QVariant QAndroidIntent:: extraVariant (const QString & key )

Returns the extra key data from the Intent extras as a QVariant

QJniObject QAndroidIntent:: handle () const

The return value is useful to call other Java API which are not covered by this wrapper

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

设置 key 采用 data in the Intent extras

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

设置 key 采用 value in the Intent extras.