QAndroidService Class

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

头文件: #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
继承于 QCoreApplication
状态:初步

该类正在开发中,可能会有更改。

公共函数

QAndroidService(int &argc, char **argv)
QAndroidService(int &argc, char **argv, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder)
virtual QAndroidBinder *onBind(const QAndroidIntent &intent)

详细说明

QAndroidService 是一个封装了最重要的Android 服务方法的便利类。

成员函数文档

QAndroidService::QAndroidService(int &argc, char **argv)

创建新的 Android 服务,将argcargv 作为参数传递。

另请参阅 QCoreApplication

QAndroidService::QAndroidService(int &argc, char **argv, const std::function<QAndroidBinder *(const QAndroidIntent &)> &binder)

创建一个新的 Android 服务,将argcargv 作为参数传递。

binder 用于在需要时创建 。binder

另请参阅 QCoreApplication

[virtual] QAndroidBinder *QAndroidService::onBind(const QAndroidIntent &intent)

用户必须覆盖此方法并返回一个粘合剂。

intent 参数包含所有调用者信息。

返回的粘合剂将被调用者用于执行 IPC 调用。

警告: 此方法由 Binder 的线程调用,该线程与创建此对象的线程不同。

另请参阅 QAndroidBinder::onTransactQAndroidBinder::transact

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