This is a walkthrough of creating a webOS mobile app using PhoneGap 0.9.5. If you’ve previously created webOS apps using older versions of PhoneGap; you will notice that the biggest difference with PhoneGap 0.9.5 is that the Mojo framework is no longer required to author webOS apps.
The first couple steps are to make sure you have all the tools and to set up your project.
- The list of necessary software & tools listed in step 3 on the PhoneGap webOS page.
- Set up your project by following step 4 on the PhoneGap webOS page, be sure to leave your terminal/cygwin window open as you will need it later.
From here you can delete or rename the index.html file (if you want to keep it as a reference) in the framework folder, we will be working on creating an app from the beginning.
- Create a new index.html file in the framework folder.
- Include the phonegap.js library in the of your index.html
- Add an onLoad method which triggers the navigator.device.deviceReady() method in the right after the reference to phonegap.js
- In the tag’s onload event call the onLoad() method
- Add the text “Hello World” within the tags
The source of your index.html should look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <html> <head> <script type="text/javascript" src="phonegap.js"></script> <script type="text/javascript"> function onLoad() { navigator.device.deviceReady(); } </script> </head> <body onload="onLoad();"> Hello World </body> </html> |
To view your work, you’ll want to either:
- open the Palm emulator
- set your Palm device to developer mode and plug it in
Go back to terminal/cygwin and type “make” (without the quotes).
Presto! You should see your hello world example app in the emulator or device.
Source can be found here.