This translation is incomplete. Please help translate this article from English.
Firefox for Android supports add-ons using the same extension system used by all other Gecko-based applications. You can use the Add-on SDK or build manually bootstrapped restartless add-ons. You can even develop traditional restart-required add-ons, although the other two approaches are preferable.
Add-ons that work with desktop Firefox do not automatically work in Firefox for Android:
- There is no visible XUL in the UI, so you can't use an overlay to create the UI.
- Internal code and objects, like
gBrowser
, do not exist. Look at the Firefox on Androidbrowser.js
file to learn about the internals. Much of the same fundamental functionality exists. - Services like
nsIPromptService
andnsIAlertsService
are implemented to use native Android UI. - There is a simple JavaScript object, called
NativeWindow
, that allows you to manipulate parts of the native Android UI.
The following articles provide help with developing extensions for Firefox on Android. In addition, please refer to the general extension documentation that applies to all Mozilla applications.
Tutorials
- Walkthrough
- Developing, packaging and installing a simple add-on for Firefox for Android.
- Firefox Hub Walkthrough
- How to develop a Firefox Hub add-on to add content to the Firefox for Android home page.
- Add-on SDK
- How to develop Firefox for Android add-ons using the Add-on SDK.
Sample code
- Code Snippets
- Code samples for common tasks.
- Initialization and Cleanup
- How to initialize your add-on when it is started and clean up when it is shut down.
- Firefox for Android Add-ons Github Repo
- A collection of JS modules, sample code, and boilerplate repos to help you build add-ons for Firefox for Android.
API reference
- NativeWindow
- Create native Android UI widgets.
- BrowserApp
- Access browser tabs and the web content they host.
- Prompt.jsm
- Show native Android dialogs.
- HelperApps.jsm
- Query and launch native apps installed on the system.
- Notifications.jsm
- Use extended properties for Android system notifications.
- Home.jsm
- Customize the home page.
- HomeProvider.jsm
- Store data to display on the home page.