我做了一个文件传送器,我希望它能回应ACTION_GET_CONTENT的意图。因此,在我的FileChooser活动中,AndroidManifest.xml中有这样的内容:
<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>(事实上,在文档中,它说添加
<data android:type="image/*" />用于选择一张照片,但Android告诉我Cannot resolve symbol 'image/*'。
然而,我的应用程序没有回应这个请求。为什么??例如,当我试图使用K9附加一个文件时,它不会响应。
我的完整AndroidManifest.xml,在这里你可以看到我的尝试:
<?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>编辑:如果我不设置,我的应用程序叫做.
发布于 2021-10-04 22:59:47
根据this answer by @CommonsWare 的说法,ACTION_GET_CONTENT是由操作系统本身管理的现代版本的安卓系统。因此,我们似乎不得不使用操作系统想要的东西。
https://stackoverflow.com/questions/69230616
复制相似问题