Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 993085 of API

  • Revision slug: Mozilla/Add-ons/Firefox_for_Android/API
  • Revision title: API
  • Revision id: 993085
  • Created:
  • Creator: wbamberg
  • Is current revision? Yes
  • Comment

Revision Content

{{AddonSidebar}}

There are a couple of differences between desktop Firefox and Firefox for Android that are particularly relevant to add-on developers:

  • there is no visible XUL in the user interface, so you can't use XUL overlays to create your add-on's UI
  • the gBrowser object does not exist, so you can't use tabbrowser to interact with browser tabs

Instead, Firefox for Android provides its own APIs:

  • NativeWindow enables you to manipulate parts of the native Android UI
  • BrowserApp enables you to interact with browser tabs
  • PageActions.jsm allows you to add buttons to the urlbar. {{fx_minversion_inline("34")}}
  • Prompt.jsm allows you to easily show native prompts, dialogs, menus, and lists
  • Notifications.jsm allows you to handle system notifcations
  • Home.jsm allows you to customize the home page
  • HomeProvider.jsm allows you to store data to show on the home page
  • Accounts.jsm allows you to start the Firefox Account set-up process
  • JavaAddonManager.jsm allows you to dynamically load and interface with compiled Java code. {{fx_minversion_inline("42")}}
  • Snackbars.jsm allows you to show Snackbar notification.  {{fx_minversion_inline("44")}}

In these pages we've documented the main functions and properties exposed by these objects. To see all the details, refer to the code at browser.js.

We also have some modules that don't ship with Firefox for Android but can be used in addons:

  • Sound.jsm lets you play sounds in the browser simply

Revision Source

<p>{{AddonSidebar}}</p>

<p>There are a couple of differences between desktop Firefox and Firefox for Android that are particularly relevant to add-on developers:</p>

<ul>
 <li>there is no visible XUL in the user interface, so you can't use XUL overlays to create your add-on's UI</li>
 <li>the <a href="https://developer.mozilla.org/en-US/docs/Code_snippets/Tabbed_browser" title="https://developer.mozilla.org/en-US/docs/Code_snippets/Tabbed_browser"><code>gBrowser</code></a> object does not exist, so you can't use <a href="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser" title="https://developer.mozilla.org/en-US/docs/XUL/tabbrowser"><code>tabbrowser</code></a> to interact with browser tabs</li>
</ul>

<p>Instead, Firefox for Android provides its own APIs:</p>

<ul>
 <li><a href="/en-US/docs/Extensions/Mobile/API/NativeWindow" title="/en-US/docs/DOM/en/Extensions/Mobile/API/NativeWindow"><code>NativeWindow</code></a> enables you to manipulate parts of the native Android UI</li>
 <li><a href="/en-US/docs/Extensions/Mobile/API/BrowserApp" title="/en-US/docs/Extensions/Mobile/API/BrowserApp"><code>BrowserApp</code></a> enables you to interact with browser tabs</li>
 <li><a href="/en-US/Add-ons/Firefox_for_Android/API/PageActions.jsm">PageActions.jsm</a> allows you to add buttons to the urlbar. {{fx_minversion_inline("34")}}</li>
 <li><a href="/en-US/docs/Extensions/Mobile/API/Prompt.jsm" title="/en-US/docs/Extensions/Mobile/API/Prompt.jsm"><code>Prompt.jsm</code></a> allows you to easily show native prompts, dialogs, menus, and lists</li>
 <li><a href="/en-US/docs/Extensions/Mobile/API/Notifications.jsm"><code>Notifications.jsm</code></a> allows you to handle system notifcations</li>
 <li><a href="/en-US/docs/Extensions/Mobile/API/Home.jsm" title="/en-US/docs/Extensions/Mobile/API/Prompt.jsm"><code>Home.jsm</code></a> allows you to customize the home page</li>
 <li><a href="/en-US/Add-ons/Firefox_for_Android/API/HomeProvider.jsm" title="/en-US/docs/Extensions/Mobile/API/Prompt.jsm"><code>HomeProvider.jsm</code></a> allows you to store data to show on the home page</li>
 <li><a href="/en-US/Add-ons/Firefox_for_Android/API/Accounts.jsm" title="/en-US/docs/Extensions/Mobile/API/Prompt.jsm"><code>Accounts.jsm</code></a> allows you to start the Firefox Account set-up process</li>
 <li><a href="/en-US/Add-ons/Firefox_for_Android/API/JavaAddonManager.jsm" title="/en-US/docs/Extensions/Mobile/API/Prompt.jsm"><code>JavaAddonManager.jsm</code></a> allows you to dynamically load and interface with compiled Java code. {{fx_minversion_inline("42")}}</li>
 <li><code><a href="/en-US/docs/Mozilla/Add-ons/Firefox_for_Android/API/Snackbars.jsm">Snackbars.jsm</a></code> allows you to show Snackbar notification.&nbsp; {{fx_minversion_inline("44")}}</li>
</ul>

<p>In these pages we've documented the main functions and properties exposed by these objects. To see all the details, refer to the code at <a class="external" href="https://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js" title="https://mxr.mozilla.org/mozilla-central/source/mobile/android/chrome/content/browser.js"><code>browser.js</code></a>.</p>

<p>We also have some modules that don't ship with Firefox for Android but can be used in addons:</p>

<ul>
 <li>
  <p><code><a href="/en-US/docs/Mozilla/Add-ons/Firefox_for_Android/API/Sound.jsm">Sound.jsm</a></code> lets you play sounds in the browser simply</p>
 </li>
</ul>
Revert to this revision