.NET Maui Filepicker not picking up Custom filetype in Android Platform

Albin Lukose 45 Reputation points
2023-11-07T00:52:59.4766667+00:00

I have created a file picker in .NET Maui to choose files of custom type(.client) . But In android platform it's not identifying the file of .client extension .The file seems to be disabled for the file picker to choose.

Please find my code below.

            var customFileType = new FilePickerFileType(
                new Dictionary<DevicePlatform, IEnumerable<string>>
                {
                    
                    { DevicePlatform.Android, new[] { "application/client" } }, 
                   
                });

            PickOptions options = new()
            {
                PickerTitle = "Please select a client file",
                FileTypes = customFileType,
            };


            var result = await FilePicker.Default.PickAsync(options);
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,080 questions
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 38,061 Reputation points Microsoft Vendor
    2023-11-08T02:09:29.6433333+00:00

    Hello,

    In Android, Google uses MIME types as a filter for file pickers.

    By referring to the list of mime.types - platform/external/mime-support - Git at Google (googlesource.com) in the Android source code, it can be found that the .client is not supported. Therefore, it is in line with the program's expectation that this happens.

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful