Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Blackberry4.6操作系统版本上加载html_Java_Blackberry - Fatal编程技术网

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

Java 在Blackberry4.6操作系统版本上加载html,java,blackberry,Java,Blackberry,嗨,我是黑莓应用程序开发新手,我想在浏览器字段中加载HTML。。 我能够加载版本5、6和更多的HTML,但它不能加载到操作系统版本4中 请告诉我如何在Blackberry OS version4.6上加载此HTML,我正在使用Eclipsed 在5和6上开发应用程序可以正常工作,但在4.6中不能告诉我如何编写。这个代码或者代码中的任何特定更改,或者我们不能在OS版本4.6中加载HTML BrowserField mybroBrowserField=new BrowserField(); add

嗨,我是黑莓应用程序开发新手,我想在浏览器字段中加载HTML。。 我能够加载版本5、6和更多的HTML,但它不能加载到操作系统版本4中

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

BrowserField mybroBrowserField=new BrowserField();

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

此代码适用于5和5以上版本,但不适用于操作系统版本4。BrowserField仅自BlackBerry API 5.0.0以来存在,但您可以使用LogicMail中的此自定义来解决您的问题。您可以用这种方式显示html文档

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

如果您使用BlackBerry 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());
        }
    };
}

并调用它,而不是makeConnectionString url、HttpHeaders requestHeaders、byte[]postData方法

我们将如何放置这个类可以告诉我,因为我已经尝试了这个不能做。我也尝试了这个,但没有工作。只要告诉我如何在浏览器字段中加载Html。在操作系统版本4.6中,它对我来说运行良好,BrowerSession从4.0开始提供。如果你能发布你的代码你到底在做什么,那么我将能够解决这个问题代码是上层的,我只想Hello world,它是HTML格式的,请看并告诉我修改后的代码。此代码适用于5和5以上版本,但当我在4.6上运行此代码时,它不起作用;addmybroBrowserField;mybroBrowserField.displayContent你好,世界!这是blackbery应用程序;在我的代码中,您必须给出位于项目资源中的html文件的名称。。。。。。。。因此,一种方法是为您的数据创建一个.html文件,并将其复制到您的项目资源中,然后指定该html文件的名称。请不要重新发布问题。