I’m developing a BlackBerry app which uses an embedded browser to display html content.
Testing application on Torch I’ve realized that only project embedded images are displayed by browser, while I’ve got problems accessing image resource files stored on removable SD card or internal file system.
The same application running on Curve displays correctly all the images.
Here is a fragment of code:
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);
I’m using JRE 5 both for Curve and Torch.
Using FileConnector to accessing file works fine.
Any suggestions on how to display images both on Torch and Curve?
Thanks
Solved!
Hereafter the code describing how I did it:
So, this works fine on Torch, but I have poor performances on Curve. I’ll specialize the behaviour depending on device type.
I know that is a workaround, but it works!