2012-04-03 33 views
0

嗨我是黑莓应用程序开发中的新手,我想在浏览器字段中加载HTML .. 我可以加载HTML版本5和6以及更多,但它不加载在操作系统版本4在Blackberry4.6操作系统版本上加载html

plz告诉我如何使用Eclipsed 在Blackberry OS版本4.6上加载这个HTML到5和6的应用程序正常工作,但在4.6没有PLZ告诉我如何写。代码为这个或任何特定的代码更改或我们不能加载HTML在操作系统版本4.6?

BrowserField mybroBrowserField=new BrowserField(); 

add(mybroBrowserField); 
mybroBrowserField.displayContent(
"<html><body><h1>hello world! This blackbery apps</h1> </body></html>", 
"http://localhost"); 

这个代码适用于5和超过5版本,但对于操作系统版本无法正常工作4

+0

请不要转发问题。 – 2012-04-04 09:29:30

回答

0

BrowserField因为黑莓5.0.0 API只存在,但你可以使用此自定义BrowserFieldRenderer class从LogicMail为您解决问题

+0

我们将如何把这个类可以告诉我,因为我已经尝试这个不能做.. – 2012-04-04 05:16:20

2

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

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

我也试过这个也不工作。只是告诉我如何加载Html在浏览器提交。 in Os版本4.6 – 2012-04-04 05:20:02

+0

它适用于我,BrowerSession可以从4.0版本获得。如果你可以发布你的代码,你到底在做什么,那么我将能够解决问题 – Nsr 2012-04-04 05:22:24

+0

代码是上我只想要世界,这是在HTML格式只是看到和PLZ告诉我修改后的代码。此代码是5和超过5版本的工作,但是当我在4.6运行此代码不工作。 – 2012-04-04 05:29:33

0

如果您正在使用黑莓Eclipse插件开发的BB应用程序,你ç一个进口样品BlackBerry项目。列表中有类似BlackBerry Browser Field Demo的内容。只需导入并了解它是如何工作的。
插入这段程式公用事业类

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)方法这一点。

相关问题