All Firefox OS applications adopt the HTML5 standard. As long as HTML, CSS, and JS are used, developing apps is very simple, but firefox OS provides some features for mobile devices, such as phones, text messages, WIFI, and 3G networks. However, you can call these functions to manipulate JS objects like common JS components. Mozilla is also negotiating with W3C to add these new features to the HTML5 standard.
There are currently two methods to deploy the Firefox OS App.
1. Before gaia compilation, describe the directory structure of the App project of your App project in detail) in the apps or test_apps directory of gaia source code, and then make
This method can be run in the simulator or burned to the B2G mobile phone to run your application.
2. Deploy your App to the web server and install it online. In this case, you need to publish your application to the App store or write a separate page for App installation so that users can install your application through this page. Detailed descriptions will be provided later.
Next we will use a simple Demo to illustrate how to develop the Firefox OS App.
1. Create a folder named testapp as the root directory of the Project. Note that the folder name must be a lowercase letter)
2. Create index.html in the testappdirectory. The Code is as follows:
- <!DOCTYPE html>
-
-
- <meta charset="utf-8" />
-
- <body>
- hello Firefox OS
- </body>
-
3. Create manifest. webapp in the testapp directory. The Code is as follows:
- {
- "name": "Test App",
- "launch_path": "/index.html",
- "developer": {
- "name": "chy",
- "url": "http://chyblog.sinaapp.com"
- },
- "appcache_path": "/cache.manifest",
- "fullscreen": "true",
- "icons": {
- "120": "/style/testApp.png"
- },
- "permissions": [
- ]
- }
Bytes
5. Deployment: We deploy testapp In the first method mentioned above, put test_apps under gaia source code, and re-compile the giai source code. Run the simulator after compilation. In your Firefox OS, you will see your new application.
6. to install the application online, first place the application on the web server and add an installation page. The source code is as follows:
- <!DOCTYPE html>
-
-
- <meta charset="UTF-8"/>
- <title>online install</title>
- <script type="text/javascript">
- function install() {
- var request = window.navigator.mozApps.install("http://demos.chyblog.com/testapp/manifest.webapp");
- request.onsuccess = function() {
- // Save the App object that is returned
- var appRecord = this.result;
- alert('Installation successful!')
- };
- request.onerror = function() {
- // Display the error information from the DOMError object
- alert('Install failed, error: ' + this.error.name);
- };
- }
- </script>
-
- <body>
- <input type="button" value="install Test App" onclick="install()"/><br>
- from:<a href="http://www.chyblog.com">http://www.chyblog.com</a>
- </body>
-
You need
- var request = window.navigator.mozApps.install("http://demos.chyblog.com/testapp/manifest.webapp");
Address secret in
After deployment, use the firefox browser in B2G to access the URL of the installation page, click the "install Test App" button, and install it as prompted. You can also use the demo page to install the application.
Effect
Source code download: http://chyblog-chyblog.stor.sinaapp.com/wp-content/uploads/2012/09/testapp.zip