停止 iOS 在 BrowserComponent 中显示文件

问题描述 投票:0回答:1

我正在使用浏览器组件来显示网页。从此页面可以下载 csv 文件。我使用 FileSystemStorage 存储文件。这效果很好。但是,在 iPhone 上,csv 将打开并显示在浏览器组件中,如下所示。

enter image description here

我要求用户提供文件名,然后保存到文件系统存储中。问题是,用户无法从上面显示的页面返回。使用 Display.getInstance().execute(filePath) 打开文件时通常会显示“完成”或共享按钮,如下所示。

enter image description here

如何停止或阻止 iOS 设备在浏览器组件中打开或显示 csv 文件?

codenameone
1个回答
0
投票

您可以使用

addBrowserNavigationCallback
控制浏览器导航,例如:

browser.addBrowserNavigationCallback(url -> {
   if(url.toLowerCase().endsWith(".csv")) {
       // it is crucial that this callback returns immediately and no
       // action be performed on the navigation callback thread...
       callSerially(() -> performDownloadLogic(url));
       return false;
   }
   return true;
});
© www.soinside.com 2019 - 2024. All rights reserved.