本文介绍了将文件扩展名与 Xamarin Android 应用程序关联的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将自定义文件扩展名与基于 Xamarin 的 Android 应用程序相关联.当用户从文件管理器中选择特定类型的文件时,我希望我的应用程序打开.

I am trying to associate a custom file extension with my Xamarin-based Android application. I would like my application to open when the user chooses a particular type of file from the file manager.

My files use the extension ".label" but for some reason I cannot get Android to add my app to the chooser listen when selecting a file with such file extension.

My files use the extension ".label" but for some reason I cannot get Android to add my app to the chooser listen when selecting a file with such file extension.

但是,如果我使用.xml"扩展名,它似乎可以工作.这是我正在使用的 IntentFilter:

However, if I use the ".xml" extension it seems to work. Here is the IntentFilter I am using:

[IntentFilter(new[] { Intent.ActionView, Intent.ActionEdit },
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataScheme = "file",
DataHost = "*",
DataMimeType = "*/*",
DataPathPattern = ".*\.xml")]

推荐答案

这对我有用:

[IntentFilter(new[] { Intent.ActionView, Intent.ActionEdit },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "file",
    DataHost = "*",
    DataPathPattern = ".*\\.label")]

这篇关于将文件扩展名与 Xamarin Android 应用程序关联的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 19:14