Current location - Quotes Website - Personality signature - How to package webapp based on ios with phonegap
How to package webapp based on ios with phonegap
For Android, Sencha's phonegap also encapsulates web programs in this way. After downloading phonegap, it mainly includes two files:

1、phonegap

This jar file contains the DroidGap class, which properly encapsulates Activity and WebView, making it easier for users to package.

The more important function is to implement multiple Webkit plug-ins, through which some system functions of android can be directly called in javascript, such as obtaining device information such as screen size and system version number, and a series of functions such as making phone calls, sending text messages and writing local files.

2、phonegap

This js file is encapsulated at a higher level, so it is more convenient to call the added plug-in function in javascript. For example, call directly in js:

A navigator. Notice. Vibration (0) can directly make the mobile phone vibrate.

And navigator.notification.Beep(2) can make the phone ring twice.

Let's try the simplest example (you can also see the example that comes with phonegap):

(1)java source code file: Sample.java.

Parcel? com . phonegap . sample; ? Import? Android . app . activity; ? Import? Android . OS . bundle; ? Import? com . phonegap . *; ? Public? Class? Sample? Extension? DroidGap? { ? @ Overwrite? Public? Invalid? OnCreate (bundle? savedInstanceState)? { ? super . oncreate(savedInstanceState); ? super . loadurl(" file:///Android _ asset/www/index . html "); ? } ? }

(2) Web page code: index.html

& lt! DOCTYPE? html & gt? & lthtml & gt? & lthead & gt? & ltmeta? http-equiv="Content-Type "? content = " text/html; ? Charset=utf-8 ">& lt script? type="text/javascript "? charset="utf-8 "? src="phonegap.0.9.4.js " >& lt/script & gt; ? < title > test ; ? & lt/head & gt; ? & ltbody & gt? & lt answer? href = " JavaScript:navigator . notification . alert(' hello ');" & gt click? I & lt/a & gt;; ? & lt/body & gt; ? & lt/html & gt;

Put this file in the assets/www/ directory of the project, and if the webpage code contains other directories, put it in this directory.

(3) Add a reference to phonegap.0.9.4.jar in the project.

When compiling and running, click the click me link in the page to see the following screen: