Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 33
Registered: ‎08-19-2010
My Device: Not Specified
Accepted Solution

Local images using cod protocol in BrowserField

Hi everybody,

 

i try to get the BrowserField displaying local images stored in my res folder.

 

for example i display a div with a background image. in the style attribute i specify the backround image url attribute:

 

cod://moduleName/image.png

 

in here moduleName is just the name of my Eclipse Project.

 

When i run my app in the simulator, everything is ok and the images are well displayed, but when i debugg my app on a device (eclipse => debug => bb device), none of my images are displayed.

 

i thought that it was due to the moduleName which was not right, but i coudn't find a way to retrieve the exact module name of my app from my app (like a getModuleName() method). When i use the AppDescriptor.currentAppDescriptor.getModuleName() (or something like that)  i got a error.

 

Thank you for your help

Regular Contributor
Posts: 77
Registered: ‎09-19-2008
My Device: Blackberry 8320
My Carrier: Airtel India

Re: Local images using cod protocol in BrowserField

Hi,

 

Instead of using "cod://moduleName/image.png", do modify  as per below instructions,

 

if OS 4.7 and lower version -

"data:///". So if you kept images in resource folder has structure "src/localresource/images/", then path should be constructed as "data:///localresource/images/image1.png"

 

if OS 5.0 and higher, using BrowserField2 API -

"local:///". So if you kept images in resource folder has structure "src/localresource/images/", then path should be constructed as "local:///localresource/images/image1.png"

 

 Let me know if it works.

Contributor
Posts: 33
Registered: ‎08-19-2010
My Device: Not Specified

Re: Local images using cod protocol in BrowserField

works perfectly. Thank you !

Highlighted
New Contributor
Posts: 4
Registered: ‎01-11-2011
My Device: Torch
My Carrier: Rogers

Re: Local images using cod protocol in BrowserField

That is great!

 

Is there any way in the BrowserField to refer to the images in the memory, which is downloaded outside of the browserfield?

 

 Thanks


if OS 5.0 and higher, using BrowserField2 API -

"local:///". So if you kept images in resource folder has structure "src/localresource/images/", then path should be constructed as "local:///localresource/images/image1.png"

 

 

New Contributor
Posts: 2
Registered: ‎10-22-2011
My Device: Simulator
My Carrier: Simulator

Re: Local images using cod protocol in BrowserField

Worked for  me. Thanks a lot.

 

I wanted use image as background.

 

Image file path -  src/img/myImage.png

background-image:url('local:///img/myImage.png')