显示使用代码名1下载并保存在文件系统中的HTML文件的正确方法是什么? [英] What is the correct way to display a HTML file downloaded and saved in the file system using codename one?

查看:146
本文介绍了显示使用代码名1下载并保存在文件系统中的HTML文件的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显示下载并保存在文件系统中的HTML文件的正确方法是什么?我可以下载并保存模拟器上的.cn1文件夹中的html页面,但它不显示。我使用旧Kitchen Kitchen demo中的Page.html示例文件进行了测试。

另外,如何使用硬编码路径,如file:/// storage / emulated / 0 /文件夹/ Page.html而不是?我已尝试过,但手机中的常用文件夹中没有任何内容出现Android文件夹。以下是我迄今为止所做的!


$ f $ b $ f $ b $ f $ b $ f $

`FileSystemStorage fs = FileSystemStorage.getInstance();`
`fs.mkdir(fs.getAppHomePath()+SampleFolder);`

`Util .downloadUrlToFile(http://somesite.com/Page.html,fs.getAppHomePath()+SampleFolder / Page.html,true);`

`BrowserComponent browser = new BrowserComponent );`
`browser.setURL(fs.getAppHomePath()+SampleFolder / Page.html);`

`fm_brw.addComponent(BorderLayout.CENTER,browser);`
`fm_brw.show();`


解决方案

@ Shai Almog - 2018年快乐,请接受我对延迟回复的道歉。我找出了网页不打折的原因......显然,在设置时必须添加 file:// url browser.setURL(file://+ str_homePath + str_filePath);



如果这不是你的设计,那么我可以提交R FE。

What is the correct way to display a HTML file downloaded and saved in the file system? I am able to download and save the html page in the .cn1 folder on Simulator but it doesn't display. I tested using the Page.html sample file found in the old Kitchen Sink demo.

Also, how can I use hardcoded paths like file:///storage/emulated/0/Folder/Page.html instead? I have tried but nothing appears in common folders in the phone e.g. the Android folder. Below is what I have done so far!

`Form fm_brw = new Form();` 
`fm_brw.setLayout(new BorderLayout());`

`FileSystemStorage fs = FileSystemStorage.getInstance();`
`fs.mkdir(fs.getAppHomePath() + "SampleFolder");`

`Util.downloadUrlToFile("http://somesite.com/Page.html", fs.getAppHomePath() + "SampleFolder/Page.html", true);`

`BrowserComponent browser = new BrowserComponent();`
`browser.setURL(fs.getAppHomePath() + "SampleFolder/Page.html);`

`fm_brw.addComponent(BorderLayout.CENTER, browser);` 
`fm_brw.show();`

解决方案

@Shai Almog - Happy 2018 and please accept my apologies for the delayed reply. I figured out the reason for the webpage not diplaying... apparently, you have to add the "file://" when setting the url i.e. browser.setURL("file://"+str_homePath+str_filePath);

If this is not by your design then I can file an RFE.

这篇关于显示使用代码名1下载并保存在文件系统中的HTML文件的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆