2
我正在開發使用嵌入式瀏覽器顯示html內容的BlackBerry應用程序。
在火炬上測試應用程序我意識到,只有項目嵌入式圖像由瀏覽器顯示,而我在訪問存儲在可移動SD卡或內部文件系統中的圖像資源文件時遇到問題。
運行在Curve上的相同應用程序正確顯示所有圖像。
下面是代碼片段:BlackBerry嵌入式瀏覽器:使用HTML的圖像顯示
browser = new BrowserField();
Strimg img_1 = "file:///store/home/user/yellow.png";
Strimg img_2 = "file:///SDCard/green.png";
Strimg img_3 = "file:///local/images/red.png";
String imgTag_1 = "<img src=\"" + img_1 + "\">"; // Stored on file system - Not displayed by Torch
String imgTag_2 = "<img src=\"" + img_2 + "\">"; // Stored on SDCard - Not displayed by Torch
String imgTag_3 = "<img src=\"" + img_3 + "\">"; // Embedded image
String browserContent = "<html>" + imgTag_1 + imgTag_2 + imgTag_3 + "</html>";
byte[] contentBytes;
try {
contentBytes = browserContent.getBytes("UTF-8");
browser.displayContent(contentBytes, "text/html; charset=UTF-8", "http://mysite.com");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
browser.displayContent(browserContent, "http://mysite.com");
}
aVerticalManager.add(browser);
我使用JRE 5無論是曲線和火炬。 使用FileConnector訪問文件可以正常工作。
關於如何在火炬和曲線上顯示圖像的任何建議? 謝謝