के लिए इरादा फ़िल्टर मैं अपने ऐप को एक्सटेंशन के साथ जोड़ने की कोशिश कर रहा हूं। मैंने समस्या के बारे में documentation और somequestions पढ़ा है। लेकिन प्रमुख फ़ाइल एक्सप्लोरर (जैसे एएस फाइल एक्सप्लोरर, एस्ट्रो, रिदम सॉफ्टवेयर द्वारा फाइल मैनेजर) मेरी फाइलें नहीं खोल सकते हैं।सामान्य फ़ाइल एक्सप्लोरर
मेरे 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 फ़ाइल प्रबंधक का उपयोग करना सबकुछ सामान्य है - सूची में बहुत से ऐप्स और मेरे ऐप के साथ लंबे चयनकर्ता दिखाए गए हैं।
लेकिन अगर मैं इसे एएस फाइल एक्सप्लोरर या लयथम फ़ाइल एक्सप्लोरर के साथ खोलने का प्रयास करता हूं - उनके कस्टम चयनकर्ता (टेक्स्ट/छवि/वीडियो/ऑडियो के रूप में खुला) दिखाता है। यह बुरा है।
और यदि मैं इसे एस्ट्रो के साथ खोलने का प्रयास करता हूं - यह ओपनइन्टेंट के फ़ाइल प्रबंधक को खोलता है। यह भी बुरा है।
क्या समस्या का कोई समाधान है? इस तरह के व्यवहार में गलत कौन है?
किसी भी मदद के लिए धन्यवाद।