PhoneGap
-
Upload
emil-varga -
Category
Technology
-
view
2.417 -
download
2
description
Transcript of PhoneGap
![Page 2: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/2.jpg)
Develop in HTML5/CSS3 + JavaScript
Deploy to multiple platforms
![Page 3: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/3.jpg)
● Free and Open Source● Large community● Plugins and tools● JavaScript frameworks
xui
![Page 4: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/4.jpg)
Native application(Java, C++, C#..)
WebView (browser)
plug-ins
Here be JavaScript and HTML
Glued with PhoneGap
Extra stuff (Barcode scanner, Speech recognizer, Soft keyboard etc.)
![Page 5: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/5.jpg)
![Page 6: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/6.jpg)
Technical details ahead
![Page 7: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/7.jpg)
● Eclipse Classic 3.4 – 3.7.x (current) http://www.eclipse.org/downloads/
● Download Android SDK, extract zip/tar, run ./android, select all, install http://developer.android.com/sdk/index.html
● Install Eclipse plugin (Help->Install New Software..)https://dl-ssl.google.com/android/eclipse/
http://phonegap.com/start#android
![Page 8: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/8.jpg)
● Download PhoneGap 1.4.1 (currently)
● Eclipse -> New -> Android Project ● Select your build target (e.g. Android 2.2)● Add your package name● Un-check creating SampleActivity.java
● Copy content of the phonegap sample project<extracted folder>/lib/android/example to the new Android Project (everything except project.properties)● Configure Build path -> Add JARs -> libs/phonegap-1.4.1.jar● Edit AndroidManifest.xml
– remove line android:xLargeScreens =”true”
– Change <uses-sdk android:minSdkVersion=”5” /> to your build target (e.g. 8)
![Page 9: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/9.jpg)
![Page 10: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/10.jpg)
//on application start wait for phonegap to fully loaddocument.addEventListener(“deviceReady”, function(){
//pop up a confirmation dialog
navigator.notification.confirm(“Do you want to exit?”,
//function called on any button pressed (Yes or No)
function(button){
//user pressed 'Yes'
if (button==1){
//exit application
navigator.app.exitApp();
} },”Confirm”, “Yes,No”);
},true);
![Page 11: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/11.jpg)
Thanks to the PhoneGap teamAnd Brian LeRoux
![Page 12: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/12.jpg)
Extra
● Pluginshttps://github.com/purplecabbage/phonegap-plugins
● Cool Tools● Lawnchair – simple NoSQL JSON
http://westcoastlogic.com/lawnchair/● ApplicationCraft – zero install developer envoronment
http://www.applicationcraft.com/● Ripple – in-browser device emulator
http://ripple.tinyhippos.com/● PhoneGap build
https://build.phonegap.com/
![Page 13: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/13.jpg)
DIY plugins
//myPlugin.js
function MyPlugin() {};
MyPlugin.prototype.myAction = function(params, winCallback, failCallback){
PhoneGap.exec(winCallback, failCallback, “MyPlugin”, “myAction”, [params]);
}
PhoneGap.addConstructor(function(){
PhoneGap.addPlugin(“myPlugin”, new MyPlugin());
});
![Page 14: PhoneGap](https://reader036.fdocuments.net/reader036/viewer/2022081403/5558153ad8b42a5e468b4a0b/html5/thumbnails/14.jpg)
DIY plugins
import com.phonegap.api.Plugin;
import com.phonegap.api.PluginResult;
import org.json.JSONArray;
import org.json.JSONObject;
public class MyPlugin extends Plugin{
public PluginResult execute(String action, JSONArray args, String callbackId){
if (action.equals(“myAction”)){
JSONObject obj = args.getJSONObject(args);
...
return new PluginResult(PluginResult.Status.OK);
}
else return new PluginResult(PluginResult.Status.INVALID_ACTION);
}
}