【发布时间】:2014-01-29 11:19:32
【问题描述】:
我正在尝试使用 android 4.4 的存储访问框架
我开发了一个虚拟应用程序,它会在活动开始时触发意图。
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
startActivityForResult(intent, READ_REQUEST_CODE);
我还开发了另一个虚拟应用程序作为文件提供者。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.saf"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.MANAGE_DOCUMENTS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.saf.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<provider
android:name="com.example.saf.MyFileProvider"
android:authorities="com.example.saf.documents"
android:exported="@bool/is_kitkat"
android:enabled="@bool/is_kitkat"
android:grantUriPermissions="@bool/is_kitkat"
android:permission="android.permission.MANAGE_DOCUMENTS">
<intent-filter>
<action android:name="android.content.action.DOCUMENTS_PROVIDER" />
</intent-filter>
</provider>
</application>
我已经实现了 MyFileProvider 类。
但是当我启动用户应用程序(触发意图的应用程序)时,我收到以下错误
android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.OPEN_DOCUMENT cat=[android.intent.category.OPENABLE] }
我只是在关注 android 的开发者文档。有什么想法我可能做错了吗?
编辑: 这是我最新的清单。 我还需要对 MyFileProvider“扩展 DocumentsProvider”进行“正确”实现吗?我现在可以在函数中返回 null 吗?
【问题讨论】:
-
你的虚拟应用程序是否使用权限
android.permission.MANAGE_DOCUMENTS? -
@SherifelKhatib - 实际上它没有该权限。但我添加并检查了。还是一样的错误。
标签: android android-intent android-activity android-4.4-kitkat storage-access-framework