Software Development

PhoneGap – HelloWorld Example via PhoneGap CLI

This post demonstrates how to create a very simple example of PhoneGap application via PhoneGap CLI.

Requirements

Stuffs used in this post.

  • npm 3.10.8
  • node v6.9.1
  • Windows 10
  • PhoneGap 6.5.1

NOTE: The installation of npm and node is not covered here.

Install PhoneGap

[wp_ad_camp_5]

  1. Create a new directory, e.g., c:\Users\user123\Desktop\phonegap\example01.
  2. Open Windows command line and change directory to that newly created directory.
  3. From the same command line window, install PhoneGap using npm

  4. Create a PhoneGap application in the same directory

    For example:

    Then, we’re done!

    Don’t close yet the command line window. We’ll get back to it to start our application a bit later.

The PhoneGap Application

The newly created project has these files in its directory.

[wp_ad_camp_4]

Let’s now modify the application for it to display “Hello world!”.

Modify index.html

Go to the www folder.

Modify index.html by adding this HTML codes

[wp_ad_camp_3]

Testing the PhoneGap Application

From the same command line window, invoke the following command.

[wp_ad_camp_2]

Note the IPs addresses. We’ll use one of them to access the PhoneGap application.

[wp_ad_camp_1]

You Might Also Like