在Blackberry4.6操作系统版本上加载html

嗨,我是黑莓应用程序开发的新手,我想在浏览器字段中加载HTML ..我能够为版本5加载HTML,以及6及更多,但它不会加载到OS版本4

请告诉我如何在Blackberry OS version4.6上加载这个HTML,使用Eclipsed开发应用程序5和6正常工作,但在4.6不plz告诉我如何写。 代码中的此代码或任何特定更改,或者我们无法在OS 4.6版中加载HTML?

BrowserField mybroBrowserField=new BrowserField(); add(mybroBrowserField); mybroBrowserField.displayContent( "

hello world! This blackbery apps

", "http://localhost");

此代码适用于5个和5个以上的版本,但不适用于OS版本4

您可以用这种方式显示您的html文档

 BrowserSession session = Browser.getDefaultSession(); session.displayPage("cod://Name of your application code file/test.html"); 

如果您使用BlackBerry Eclipse Plug-in开发BB应用程序,则可以导入示例BlackBerry项目。 在列表中有类似BlackBerry Browser Field Demo的内容。 只需导入它,并找出它是如何工作的。
将此代码段插入Utilities类

 private static DataInputStream dataInput; private static InputStream in; static HttpConnection makeDummyConnection(String htmlData){ try { in = new ByteArrayInputStream(htmlData.getBytes("UTF-8")); dataInput = new DataInputStream(in); } catch (Exception e) { System.out.println("HttpConnectionImpl : Exception : " + e); } return new HttpConnection() { public String getURL() { return ""; } public String getProtocol() { return ""; } public String getHost() { return ""; } public String getFile() { return ""; } public String getRef() { return ""; } public String getQuery() { return ""; } public int getPort() { return 0; } public String getRequestMethod() { return ""; } public void setRequestMethod(String s) throws IOException { } public String getRequestProperty(String s) { return ""; } public void setRequestProperty(String s, String s1) throws IOException { } public int getResponseCode() throws IOException { return 200; } public String getResponseMessage() throws IOException { return ""; } public long getExpiration() throws IOException { return 0; } public long getDate() throws IOException { return 0; } public long getLastModified() throws IOException { return 0; } public String getHeaderField(String s) throws IOException { return ""; } public int getHeaderFieldInt(String s, int i) throws IOException { return 0; } public long getHeaderFieldDate(String s, long l) throws IOException { return 0; } public String getHeaderField(int i) throws IOException { return ""; } public String getHeaderFieldKey(int i) throws IOException { return ""; } public String getType() { return "text/html"; } public String getEncoding() { return "text/html"; } public long getLength() { return 7000; } public InputStream openInputStream() throws IOException { return in; } public DataInputStream openDataInputStream() throws IOException { return dataInput; } public void close() throws IOException { } public OutputStream openOutputStream() throws IOException { return new ByteArrayOutputStream(); } public DataOutputStream openDataOutputStream() throws IOException { return new DataOutputStream(new ByteArrayOutputStream()); } }; } 

并调用此而不是makeConnection(String url, HttpHeaders requestHeaders, byte[] postData)方法。

BrowserField仅在BlackBerry API 5.0.0之后存在,但您可以使用LogicMail中的此自定义BrowserFieldRenderer类来解决您的问题