user12083622
user12083622

Reputation:

Xamarin.Forms - Open file with default app

I need to open a file from storage. I used Launcher.OpenAsync(), but it always tries to open the file in PDF reader. Is there any other way to open a file with default app on Android?

This is the code I have already tried.

private void OpenDocument(string filePath)
{
    var localFile = "file://" + filePath;
    Launcher.OpenAsync(localFile);
}

Upvotes: 3

Views: 5877

Answers (1)

Radmir Safiullin
Radmir Safiullin

Reputation: 71

string path = "your uri bla-bla-bla";

 Launcher.OpenAsync
                (new OpenFileRequest()
                {
                    File = new ReadOnlyFile(path)
                }
            );

Upvotes: 7

Related Questions