QAndroidServiceConnection Class
封装 Android ServiceConnection 类最重要的方法。更多
头文件: | #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 |
状态: | 初步 |
该类正在开发中,可能会有变动。
公共函数
QAndroidServiceConnection() | |
QAndroidServiceConnection(const QJniObject &serviceConnection) | |
QJniObject | handle() const |
virtual void | onServiceConnected(const QString &name, const QAndroidBinder &serviceBinder) = 0 |
virtual void | onServiceDisconnected(const QString &name) = 0 |
详细说明
QAndroidServiceConnection 是一个方便的抽象类,它封装了AndroidServiceConnection接口。
它在执行QtAndroidPrivate::bindService 操作时非常有用。
成员函数文档
QAndroidServiceConnection::QAndroidServiceConnection()
创建一个新对象
[explicit]
QAndroidServiceConnection::QAndroidServiceConnection(const QJniObject &serviceConnection)
从现有serviceConnection 创建一个新对象。
当您有自己的 Java 实现时,它将非常有用。当然,onServiceConnected()/onServiceDisconnected() 不会再被调用。
QJniObject QAndroidServiceConnection::handle() const
返回下划线QJniObject
[pure virtual]
void QAndroidServiceConnection::onServiceConnected(const QString &name, const QAndroidBinder &serviceBinder)
当客户端成功连接到服务时,会调用此通知。name 包含服务器名称,serviceBinder 是客户端用于执行 IPC 操作的粘合剂。
警告: 此方法由粘合剂线程调用,该线程与创建此对象的线程不同。
返回下划线QJniObject
[pure virtual]
void QAndroidServiceConnection::onServiceDisconnected(const QString &name)
当与服务的连接丢失时调用。name 参数指定丢失的连接。
警告: 此方法在 Binder 的线程中调用,该线程与创建此对象的线程不同。
返回下划线QJniObject
© 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.