Search code examples
androidfilexamarinintentfilter

Associate file extension with Xamarin Android application


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.

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")]

Solution

  • This ended up working for me:

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