简体   繁体   English

Qt Quick Android:如何集成无障碍服务

[英]Qt Quick Android : How to integrate an Accessibility Service

I'm working on an Android application which runs an accessibility service. 我正在运行可访问性服务的Android应用程序。 I have developed the service java class and configuration xml files in Android Studio to test it as native app. 我已经在Android Studio中开发了服务Java类和配置xml文件,以将其作为本机应用程序进行测试。 When I run it, the accessibility service appears in the Android Accessibility Settings as expected and I can enable it. 当我运行它时,可访问性服务会按预期显示在“ Android可访问性设置”中,并且可以启用它。

However I would like to integrate this service in a Qt Quick Android application. 但是,我想将此服务集成到Qt Quick Android应用程序中。 When I do this by adding the same java class, Manifest and configuration xml files, the project compiles and runs well but the service doesn't appear in Android Settings. 当我通过添加相同的Java类,清单和配置xml文件来执行此操作时,项目将编译并运行良好,但该服务未出现在Android设置中。

Here are my configuration files: 这是我的配置文件:

Manifest.xml: Manifest.xml:

<activity
...
</activity>
<service android:name="com.myCompany.app.MyService"
         android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
        <intent-filter>
            <action android:name="android.accessibilityservice.AccessibilityService"/>
        </intent-filter>
        <meta-data android:name="android.accessibilityservice"/>
        <meta-data android:resource="@xml/accessibilityservice"/>
</service>

accessiblityservice.xml: accessiblityservice.xml:

<?xml version="1.0" encoding="utf-8"?>
<accessibility-service
xmlns:tools="http://schemas.android.com/tools"
android:accessibilityEventTypes="typeWindowStateChanged"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagIncludeNotImportantViews"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="UnusedAttribute"/>

Can some one tell me where I'm wrong ? 有人可以告诉我我错了吗?

I found the mistake by myself. 我自己发现了错误。 In the manifest.xml the meta-data tag should be on a single line, like below: 在manifest.xml中,元数据标记应位于一行上,如下所示:

<activity>
...
</activity>
<service android:name="com.myCompany.app.MyService"
         android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
        <intent-filter>
            <action android:name="android.accessibilityservice.AccessibilityService"/>
        </intent-filter>
        <meta-data android:name="android.accessibilityservice"
                   android:resource="@xml/accessibilityservice"/>
</service>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM