Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Hello, World!

As with any developer book, we’re going to start with the default HelloWorld application and then build upon it to highlight different aspects of a PhoneGap application. The following HTML content describes a simple web page that displays some text on a page.


HelloWorld1 Application

<!DOCTYPE HTML> 
<html> 
<head> 
  <title>HelloWorld1</title>   
</head> 
<body> 
  <h1>Hello World</h1>   
  <p>This is a sample PhoneGap application</p>   
</body> 
</html> 


If you package that page into a PhoneGap application and run it on a smartphone or device emulator (in this case an Android emulator), you will see something similar to what is shown in Figure 2-1.

Image

Figure 2-1 HelloWorld1 application running on an Android emulator

This is technically a PhoneGap application because it’s a web application running within the PhoneGap native application container. There is, however, nothing PhoneGap-ish about this application. It’s running in the PhoneGap native container, but it isn’t leveraging any of the APIs provided by the PhoneGap framework.

Therefore, any web application can be built into a PhoneGap application; there’s nothing forcing you to use the PhoneGap APIs. If you have a simple web application that simply needs a way to be deployed through a smartphone app store, then this is one way to accomplish that goal.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint