首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的文件管理员不回应ACTION_GET_CONTENT的意图?

为什么我的文件管理员不回应ACTION_GET_CONTENT的意图?
EN

Stack Overflow用户
提问于 2021-09-18 00:15:47
回答 1查看 127关注 0票数 0

我做了一个文件传送器,我希望它能回应ACTION_GET_CONTENT的意图。因此,在我的FileChooser活动中,AndroidManifest.xml中有这样的内容:

代码语言:javascript
复制
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.OPENABLE" />
        </intent-filter>

(事实上,在文档中,它说添加

代码语言:javascript
复制
            <data android:type="image/*" />

用于选择一张照片,但Android告诉我Cannot resolve symbol 'image/*'

然而,我的应用程序没有回应这个请求。为什么??例如,当我试图使用K9附加一个文件时,它不会响应。

我的完整AndroidManifest.xml,在这里你可以看到我的尝试:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.floritfoto.apps.xvf"
    android:versionCode="108"
    android:versionName="3.9">

    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
    <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"
        tools:ignore="ScopedStorage" />

    <application
        tools:ignore="AllowBackup"
        android:supportsRtl="false"
        android:allowBackup="true"
        android:requestLegacyExternalStorage="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:name="com.floritfoto.apps.xvf.ZForDebug"
        android:theme="@style/MyThemeNonFS" >
        <activity
            android:name=".XvfActivity"
            android:label="@string/app_name"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <!--
                -->
            </intent-filter>
        </activity>

        <activity
            android:exported="true"
            android:name=".Thumbs" >
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.LAUNCHER" />
                <!--
                -->
            </intent-filter>
        </activity>
        <activity
            android:name=".Foto"
            android:exported="true"
            tools:ignore="ExportedActivity">
            <intent-filter tools:ignore="AppLinkUrlError">
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="image/*" />
            </intent-filter>
        </activity>
        <activity
            android:name="XvfPreferences"
            android:label="Settings">
        </activity>
        <activity
            android:name="FolderList"
            android:label="Fima"
            android:exported="true"
            android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"
            android:icon="@drawable/fima_launcher_128" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <!--
                -->
            </intent-filter>
        </activity>
        <activity
            android:name="FileChooser"
            android:label="File Chooser"
            android:exported="true">
            <intent-filter>
                <action android:name="org.openintents.action.PICK_FILE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.openintents.action.PICK_FILE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.openintents.action.PICK_FILE" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.openintents.action.PICK_DIRECTORY" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:scheme="file" />
            </intent-filter>
            <intent-filter>
                <action android:name="org.openintents.action.PICK_DIRECTORY" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.OPENABLE" />
                <data android:mimeType="*/*" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.OPENABLE" />
                <data android:scheme="file" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.OPENABLE" />
            </intent-filter>
        </activity>
        <provider
            android:name="androidx.core.content.FileProvider"
            android:authorities="${applicationId}.provider"
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/provider_paths"/>
        </provider>

    </application>

</manifest>

编辑:如果我不设置,我的应用程序叫做.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-04 22:59:47

根据this answer by @CommonsWare 的说法,ACTION_GET_CONTENT是由操作系统本身管理的现代版本的安卓系统。因此,我们似乎不得不使用操作系统想要的东西。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69230616

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档