如何在使用 BlackBerry BrowserSession 时隐藏浏览器顶部栏
我正在尝试创建一个应用程序,该应用程序在运行时会重定向到某个网页。我希望这个应用程序是全屏的,没有标题栏或浏览栏。我可以调用 BrowseSession 在浏览器中打开正确的网站,但它没有给我想要的感觉。
以下是我用于 BrowseSession 的代码:
BrowserSession browser = Browser.getDefaultSession();
browser.displayPage("http://www.stackoverflow.com");
我已经研究过使用 BrowseField 来实现此目的,但我发现它的行为方式与常规 BrowseSession 不同。设备后退按钮会关闭应用程序,并且当运行 JavaScript 代码时,我的模拟器中会收到错误消息。我的代码如下:
String baseURL = "http://www.stackoverflow.com";
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
BrowserField browserField = new BrowserField(config);
add(browserField);
browserField.requestContent(baseURL);
任何帮助将不胜感激。
I am trying to create an app that will redirect to a certain webpage when run. I would like this app to be full screen with no title bar or browse bar. I am able to call a BrowseSession to bring up the proper website in the browser but it doesn't give me the desired feel.
Here is the code I am using for the BrowseSession:
BrowserSession browser = Browser.getDefaultSession();
browser.displayPage("http://www.stackoverflow.com");
I have looked into using a BrowseField for this but I find that it does not act in the same fashion as a regular BrowseSession. The device Back Button closes the app and I receive errors in my simulator when JavaScript code is being run. My code for this follows:
String baseURL = "http://www.stackoverflow.com";
BrowserFieldConfig config = new BrowserFieldConfig();
config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED, Boolean.TRUE);
BrowserField browserField = new BrowserField(config);
add(browserField);
browserField.requestContent(baseURL);
Any help will be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法以编程方式控制浏览器的整体外观,因此如果您使用
BrowserSession
,您将陷入标题栏和浏览栏的困境。在某些模拟器上,
BrowserField
的 JavaScript 被破坏了,尽管我认为它可能在所有实际设备上工作(尽管如果它不起作用我也不会感到惊讶)。我唯一可以建议的是处理和取消 ESC 键(又名后退按钮)按下,这至少应该阻止应用程序关闭。
There is no way to control the overall appearance of the browser programmatically, so you're stuck with the title bar and browse bar if you use
BrowserSession
.And JavaScript is broken for
BrowserField
on some of the simulators, although I think it may work on all the actual devices (although I wouldn't be surprised if it didn't work).The only thing I can suggest is handling and cancelling the ESC key (aka the back button) press, which should at least prevent the app from closing.