Intent - Android.Intent.action.open_documentを処理するアクティビティは見つかりませんでした
質問
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を返すだけですか?
解決
他のヒント
すべてのファイルを開くには、この行を追加します。
intent.setType("*/*") ;
.
と画像を表示するためにフィルタリングする必要がある場合は、この行を追加してください。
intent.setType("image/*");
. あなたの意図を唱えるだけで、
のように Intent intent = new Intent("android.intent.action.GET_CONTENT");
((Intent)intent).addCategory("android.intent.category.OPENABLE");
((Intent)intent).setType("*/*");
. 所属していません StackOverflow