1

I'm working on a bootstrapped extension for firefox android, and I have a problem with displaying icons in a new menu item:

    itemMenuId = window.NativeWindow.menu.add("Show more details",ico , function() {   showToast(window); });

in ico I wrote the uri of the icon file existing in the root of my extension (icon.png is next to bootstrap.js), using data: and file://, like described here but the icon isn't displayed. I don't know how to fix the path for that. Beside I'm having the same problem with the iconURL in the install.rdf file, when I use chrome:// I get nothing, and when I use resource:// I get a missing image. Should I have chrome.manifest to use chrome://? and even if I don't specify the url,to let the image be displayed by default like here it still doesn't work.

    <em:iconURL>resource://trackdetect/icon.png</em:iconURL>

I googled it ,but, I couldn't fix it. Please help and thanks.

paa
  • 5,048
  • 1
  • 18
  • 22
user2102196
  • 99
  • 1
  • 7

2 Answers2

0

Erik Vold's guide explains how to reference files packaged within a bootstrapped extension.

However it is strange that the icon doesn't appear at the addons list (you don't specify a iconURL, just place icon.png next to bootstrap.js, as you did). Perhaps you should check if the tool you use creates PNGs that conform to the standard.

paa
  • 5,048
  • 1
  • 18
  • 22
  • I used that guide to get the path of the icon: (function(global) global.include = function include(src) ( Services.scriptloader.loadSubScript(src, global)))(this); var ico; function startup(data) AddonManager.getAddonByID(data.id, function(addon) { ico = addon.getResourceURI("icon.png").spec; }); – user2102196 Jun 20 '13 at 21:33
  • but, nothing happened, it's even worse, I usded to have a slight space before the label of the menu item, and when I used this it disapeard. I didn't understand the meaning of "PNGs that conform to the standard", could you please give me further explanation and thank you. – user2102196 Jun 20 '13 at 21:40
0

For the issue, just make sure you have a file named icon.png in the root of the XPI (the same folder as bootstrap.js) and the image will be used. You don't even need the entry in the manifest. See: https://developer.mozilla.org/en-US/docs/Install_Manifests#iconURL

Mark Finkle
  • 966
  • 4
  • 5
  • Hi, thanks for the answer, I do have the icon.png in the root of the extension, but, it is not displayed. Actually, I'm wondering, maybe the problem is with the packaging of the extension, I'm using your [skeleton-addon-fxandroid on GitHub](https://github.com/mfinkle/skeleton-addon-fxandroid) (thanks by the way), but I didn't add the icon.png to the root files list to be packaged, should I ? Thank you for you time and patience. – user2102196 Jun 23 '13 at 19:53
  • Yes, you need to add any file to be packaged to the config. In this case, in the root files. – Mark Finkle Jun 24 '13 at 14:19