Xamarin.Forms - 使用默认应用打开文件 [英] Xamarin.Forms - Open file with default app
本文介绍了Xamarin.Forms - 使用默认应用打开文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从存储中打开一个文件.我使用了 Launcher.OpenAsync()
,但它总是尝试在 PDF 阅读器中打开文件.有没有其他方法可以在 Android 上使用默认应用打开文件?
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);
}
推荐答案
string path = "your uri bla-bla-bla";
Launcher.OpenAsync
(new OpenFileRequest()
{
File = new ReadOnlyFile(path)
}
);
这篇关于Xamarin.Forms - 使用默认应用打开文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文