Hi I\'m new in Blackberry app development i want to load HTML in browser field.. I\'m able to load HTML for version 5 ,and 6 and more but it not loading in OS version 4
BrowserField exist only since BlackBerry API 5.0.0, but you can use this custom BrowserFieldRenderer class from LogicMail to solve your problem
If you are using BlackBerry Eclipse Plug-in to develop BB apps, you can import sample BlackBerry projects. In the list there is something like BlackBerry Browser Field Demo. Just import that and find out how this works.
Insert this snippet to Utilities class
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());
}
};
}
and call this instead of makeConnection(String url, HttpHeaders requestHeaders, byte[] postData)
method.
You can show your html document in this way
BrowserSession session = Browser.getDefaultSession();
session.displayPage("cod://Name of your application code file/test.html");