【问题标题】:Android: "Element intent-filter is not allowed here" inside <provider>?Android:<provider> 中的“此处不允许使用元素意图过滤器”?
【发布时间】:2016-08-15 10:48:15
【问题描述】:

http://developer.android.com/guide/topics/providers/document-provider.html#manifest 展示了如何在清单中注册自定义文档提供程序:

<manifest... >
    ...
    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />
        ....
        <provider
            android:name="com.example.android.storageprovider.MyCloudProvider"
            android:authorities="com.example.android.storageprovider.documents"
            android:grantUriPermissions="true"
            android:exported="true"
            android:permission="android.permission.MANAGE_DOCUMENTS"
            android:enabled="@bool/atLeastKitKat">
            <intent-filter>
                <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
            </intent-filter>
        </provider>
    </application>

</manifest>

这个 元素在这里是必需的,但 Android Studio 抱怨:

此处不允许使用元素意图过滤器

the documentation for the provider element 似乎也表明了这一点:

CAN CONTAIN:
<meta-data> 
<grant-uri-permission> 
<path-permission>

这是 Android Studio 和文档错误还是我遗漏了什么?

【问题讨论】:

  • 我为您的错误报告加注了星标,但历史表明它可能会被忽略。只有一小部分针对 Android 提出的错误会得到官方评论,更不用说修复了。

标签: android android-studio android-manifest android-xml storage-access-framework


【解决方案1】:

你没有错过任何东西; Android Studio 和文档不正确。与任何其他组件一样,提供程序会通过意图匹配进行发现。

Android 使用如下代码查找文档提供者:

意图 i = new Intent(DocumentsContract.PROVIDER_INTERFACE);

列出 提供者 = packageManager.queryIntentContentProviders(i, 0);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-02
    相关资源
    最近更新 更多