简体   繁体   English

如何创建可访问性服务的元数据引用的 XML 文件?

[英]How can you create an XML file that is referenced by the metadata of an accessibility service?

This question might seem very simple to answer, but I seem to be having a problem with adding an XML that's referenced by my accessibility service's metadata.这个问题似乎很容易回答,但我似乎在添加一个由我的辅助功能服务的元数据引用的 XML 时遇到问题。 I tried many things, but couldn't find a solution.我尝试了很多东西,但找不到解决方案。 I placed the reference XML file for the metadata under res > xml and I don't see why it shouldn't work.我将元数据的参考 XML 文件放在res > xml下,但我不明白为什么它不应该工作。

This is the code I have for my AndroidManifest.xml file:这是我的AndroidManifest.xml文件的代码:

''' '''

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">

        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <service android:name=".myAccessibilityService"
            android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
            android:label="detectClick">


            <intent-filter>
                <action android:name="android.accessibilityservice.AccessibilityService" />
            </intent-filter>

            <meta-data
                android:name="android.accessibilityservice"
                android:resource="@xml/accessibility_service_config" />


        </service>
    </application>

</manifest>

''' '''

This is how my XML file looks like:这就是我的 XML 文件的样子:

''' ''' ''' '''

I expected the "android" to be color-coded, but it doesn't seem that way, causing my service to not request certain permissions (which means it's not working).我希望“android”是彩色编码的,但似乎不是这样,导致我的服务不请求某些权限(这意味着它不工作)。 Something interesting that happened was that when I deleted the XML file for the metadata, the error detector tried to automatically create an XML with fields I wasn't familiar with.发生的一件有趣的事情是,当我删除元数据的 XML 文件时,错误检测器尝试自动创建一个包含我不熟悉的字段的 XML。 I was thinking it had something to do with this, but wasn't sure:我认为这与此有关,但不确定:

''' ''' ''' '''

Any help would be greatly appreciated.任何帮助将不胜感激。

I seemed to solve the problem by fiddling around a little.我似乎通过摆弄一点来解决这个问题。 Take a look:看一看:

<accessibility-service android:accessibilityEventTypes="typeViewClicked|typeViewFocused"
android:packageNames="com.example.android.myFirstApp, com.example.android.mySecondApp"
android:accessibilityFeedbackType="feedbackSpoken"
android:notificationTimeout="100"
android:settingsActivity="com.example.android.apis.accessibility.TestBackActivity"
android:canRetrieveWindowContent="true"
xmlns:android="http://schemas.android.com/apk/res/android" />

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

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