如何在 Android 和 Blackberry 模拟器中打开本地 .html 文件进行测试?
如何在 Android 和 Blackberry 模拟器中打开本地 .html 文件?
我可以从互联网上打开任何网址,但我正在本地 PC 上开发一个移动网站,并且我想在模拟器中运行本地开发的 HTML 文件。
How to open local .html file in Android and Blackberry emulators?
I'm able to open any url from internet, but I'm developing a site for mobile on my local PC and I want to run my locally developed HTML files in emulators.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以通过 Android 模拟器通过 10.0.2.2 访问本地 PC。如果您想测试本地文件系统上的 HTML 文件,您需要从某个 HTTP 服务器提供这些文件。我用于此目的的一个非常简单的方法是 mongoose,它可以为任何本地目录提供服务,而无需任何配置。
我没有使用 Blackberry 模拟器的经验,但您应该能够使用其网络 IP 地址访问本地 PC。您可以使用与 Android 模拟器相同的方式从本地 HTTP 服务器访问 HTML 文件。
You can access the local PC from the Android emulator via 10.0.2.2 . If you want to test the HTML files on the local filesystem, you need to serve these files from some HTTP server. A very simple one that I use for this purpose is mongoose, that can serve any local directory without any configuration.
I have no experience with the Blackberry emulator, but you should be able to access the local PC using its network IP address. You can access the HTML files from the local HTTP server in the same way as with the Android emulator.
我不能代表黑莓,但在 Android 上你可以通过创建一个简单的活动来做到这一点。您需要在布局中使用 WebView,类似这样的操作:
然后在您的活动 onCreate 方法中,您需要找到对 WebView 的引用,并使用 html 文件的文件路径调用加载 URL 方法。
要使此示例正常工作,您必须将 html 文件放入项目的 asset 文件夹中。如果您尝试在不创建应用程序的情况下查看 html 文件,这可能会比较棘手。在实际设备上,我知道您可以将 html 文件放入 SD 卡上,然后使用文件管理器程序导航到该文件,然后使用离线浏览器打开它,但我不知道这是否适用于模拟器。
I cannot speak for blackberry, but on android you can do this by creating a simple activity. You'll want a WebView in the layout something like this would work:
Then in your activities onCreate method you'll need to find the reference to your webview and call the load URL method with the filepath to your html file.
for this example to work you'll have to put your html file into the assets folder in your project. If you are trying to view your html file without creating an application it may be trickier. On actual devices I know you can put an html file onto the SD card and navigate to it with a file manager program and open it with Offline Browser I don't know if that will work on the emulator though.
答案在发布
黑莓模拟器文件系统:它在哪里?
中提供。用 BB9900 模拟器自己的话来说,用于一个简单的 HTML5 项目,Windows XP。
1. 启动BB模拟器。
2. ALT-C(更换SD卡)
3.点击最左边的图标“添加目录”,然后遍历文件系统找到
您正在开发的本地应用程序所在的文件夹(例如 C:\temp\myapp)
4.单击右侧第二个图标(选择安装)
5. 单击关闭(右下角图标)
此时,如果您使用文件浏览器应用程序,您现在可以访问拥有本地应用程序的 PC 的文件系统并对其进行测试。
有人建议通过网络服务器提供服务......不需要。
The answer is provided in posting
Blackberry Simulator FileSystem: where is it?
In my own words, using the BB9900 Simulator, for a simple HTML5 project, Windows XP.
1. Start the BB simulator.
2. ALT-C (change SD Card)
3. click on the leftmost icon "add directory" and then traverse the file system to find the
folder where you have the local app you are developing (e.g. C:\temp\myapp)
4. click on the second icon from the right (Mount selected)
5. click on close (bottom right icon)
At this point if you use the File browser application you can now access the file system of your PC where you have your local app and test it.
Someone suggested to serve it through a web server ... not needed.