在我的应用中打开某种文件类型 [英] Open a certain file type in my app
本文介绍了在我的应用中打开某种文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序生成.smbf文件,当用户希望使用文件管理器应用程序打开文件时,我想选择在我的应用程序中打开这些文件.搜索之后,我发现了使用意图过滤器的方法,这是我的代码:
My app generates .smbf files and I want to make an option to open these files in my app when user want to open them using file manager apps. After searching I found a way using intent filter and this is my code:
[Android.App.Activity(Label = "Setting", Theme = "@style/MyTheme", WindowSoftInputMode = SoftInput.StateHidden, Icon = "@drawable/Icon")]
[Android.App.IntentFilter(actions: new string[] { Intent.ActionView, Intent.ActionEdit }, Categories = new string[] { Intent.CategoryDefault }, DataPathPattern = @".*\\.smbf", DataHost = "*", DataScheme = "file")]
public class Setting : MyActivity
{..}
生成的清单:
<activity android:icon="@drawable/icon" android:label="Setting" android:theme="@style/MyTheme" android:windowSoftInputMode="stateHidden|adjustUnspecified" android:name="md5307edafcc42f816474105a485627044f.Setting">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data android:host="*" android:pathPattern=".*\\.smbf" android:scheme="file" />
</intent-filter>
</activity>
但是可以打开* .smbf文件的应用列表中没有显示我的应用.(已通过solid和es文件浏览器测试)我还有什么需要做的?
But my app isn't shown in the list of apps that can open *.smbf file. (tested with solid and es file explorers) Is there anything more that I should do?
推荐答案
添加mimeType属性后,我的问题已解决: DataMimeType ="*/*"
android:mimeType ="*/*
My problem has been solved after I added mimeType attribute:
DataMimeType = "*/*"
android:mimeType="*/*
这篇关于在我的应用中打开某种文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文