Learn as you can developing software for mobile devices using only html, css and javascript and how you can use Spring Framework in software for mobile devices
23. What I'm able to do? ...and coming soon: camera, maps and file manager
24. Examples //GEO REFERENCING var getLocation = function () { var suc = function ( p ){ alert ( p . coords . latitude + " " + p . coords . longitude ); }; var fail = function (){ alert ( "Location not available!" );}; navigator . geolocation . getCurrentPosition ( suc , fail , undefined ); } //VIBRACALL navigator . notification . vibrate ( 0 ); //BEEEEEEP navigator . notification . beep ( 2 );
25. Examples //ACCELEROMETER var watchAccel = function () { var s = function ( a ){ document . getElementById ( 'x' ). innerHTML = roundNumber ( a . x ); document . getElementById ( 'y' ). innerHTML = roundNumber ( a . y ); document . getElementById ( 'z' ). innerHTML = roundNumber ( a . z ); }; var d = function (){}; var opt = {}; opt . frequency = 100 ; Timer = navigator . accelerometer . watchAcceleration ( s , f , opt ); } //CAMERA navigator . camera . getPicture ( dump_pic , fail , { quality : 50 }); function dump_pic ( data) { ... document . getElementById ( "test" ). src = "data:image/jpeg;base64," + data ; }
26. Where's the trick? PhoneGap give us a startup project for every supported device. Every project is a simple application made of a web browser that work as a fullscreen app and where javascripts object will be injected. These objects has native API counterpart inside the device. We need to copy html, css, javascript and images into a specific project folder for every device that we need to deploy on. We also need to modify the project configuration, like project's name, author and so on... For Android copy these files into: ../my-android/assets/www/
27. Just to explain... ...take a look at this piece of code extracted from DroidGap.java included in the Android startup project: private void bindBrowser(WebView appView) { gap = new PhoneGap( this , appView); geo = new GeoBroker(appView, this ); accel = new AccelListener( this , appView); launcher = new CameraLauncher(appView, this ); // This creates the new javascript interfaces for PhoneGap appView.addJavascriptInterface( gap , "DroidGap" ); appView.addJavascriptInterface( geo , "Geo" ); appView.addJavascriptInterface( accel , "Accel" ); appView.addJavascriptInterface( launcher , "GapCam" ); }
47. SpringME produce the code through the Apache Maven plugin Person instance = new Person(); instance.setName("Wilfred Springer"); --------------------------------------------------------- BeanFactory factory = new BeanFactory(); Person frank1 = (Person)factory.getBean(“frank”); Person frank2 = factory.getFrank();
63. Modify the MavenAndroidActivity.java: public void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); TextView tv = new TextView( this ); tv.setText(((Greeting)new BeanFactory().getBean( "ciao" )) .to( "MavenAndroidActivity" )); //oppure: tv.setText(((Greeting)new BeanFactory().getCiao()).to(...)); }
64. Repeat 8 and 9 steps mvn com.jayway.maven.plugins.android.generation2:maven-android-plugin:deploy