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

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

Highlighted
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 !

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')