Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Xamarin.Android to open a certain file type with my app? [duplicate]

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")]
like image 541
gonzobrains Avatar asked Dec 07 '25 01:12

gonzobrains


1 Answers

This ended up working for me:

[IntentFilter(new[] { Intent.ActionView, Intent.ActionEdit },
    Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
    DataScheme = "file", 
    DataHost = "*",     
    DataPathPattern = ".*\\\\.label")]
like image 96
gonzobrains Avatar answered Dec 08 '25 14:12

gonzobrains



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!