アプリを拡張機能に関連付けようとしています。ドキュメントと問題に関するいくつかの 質問を読みました。しかし、主要なファイル エクスプローラー (es ファイル エクスプローラー、astro、Rhythm ソフトウェアのファイル マネージャーなど) でファイルを開くことができません。
私のmanifest
ファイル:
<activity android:name="com.comapping.android.map.MapActivity" android:configChanges="orientation|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="file" android:host="*" android:pathPattern=".*\\.comap" android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" android:host="*" android:pathPattern=".*\\.comap" android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
そして、次のコードを使用してアプリケーションからファイルを開こうとすると、すべて正常に動作します (セレクターは表示されません):
String extension = "";
int dotIndex = downloadedFile.lastIndexOf('.');
if (dotIndex != -1) {
extension = downloadedFile.substring(dotIndex + 1, downloadedFile.length());
}
// create an intent
Intent intent = new Intent(android.content.Intent.ACTION_VIEW);
Uri data = Uri.fromFile(new File(downloadedFile));
String type = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (type == null || type.length() == 0) {
// if there is no acceptable mime type
type = "application/octet-stream";
}
intent.setDataAndType(data, type);
// get the list of the activities which can open the file
List resolvers = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
if (resolvers.isEmpty()) {
(new AlertDialog.Builder(context)
.setMessage(R.string.AttachmentUnknownFileType)
.setNeutralButton(R.string.NeutralButtonText, null)
.create()).show();
} else {
context.startActivity(intent);
}
OpenIntentsファイルマネージャーを使用して開こうとすると、すべてが正常です-リストに多くのアプリと私のアプリが表示された長いチューザーが表示されました。
しかし、es ファイル エクスプローラーまたは Rhythm ファイル エクスプローラーで開こうとすると、カスタム チューザー (テキスト/画像/ビデオ/オーディオとして開く) が表示されます。これは悪いです。
Astro で開こうとすると、OpenIntent のファイル マネージャーが開きます。それも悪いです。
問題の解決策はありますか?そのような行動で誰が間違っていますか?
助けてくれてありがとう。