Top Banner
Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate
39

Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Dec 28, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Java Mobile Apps with GWT & PhoneGap

Josh Marinacci, webOS Developer Advocate

Page 2: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

overview

•the problem

•what are gwt & phone gap

•building an app

•device apis

•fun stuff!

Page 3: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

josh: java ninja

Page 4: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Open Source Project Founder

Page 5: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 6: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 7: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Swing, JavaFX, JavaStore

Page 8: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 9: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 10: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 11: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

JavaScript

Page 12: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 13: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.
Page 14: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

the problem

•no Java on iOS, webOS, PlayBook OS and others

•we want to code in Java

•we want to use web technologies

Page 15: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

the solution

•GWT cross compiler

•PhoneGap build scripts

•Open source API bindings

Page 16: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

what is GWT?

•Google Web Toolkit

•compiler: Java to JavaScript

•UI Toolkit & JavaSE APIs

•optimized by smart Googlers

•works on any WebKit!

Page 17: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

How GWT works

•write Java code against GWT APIs

•debug with your Java IDE

•compile to optimized JavaScript

•run in any browser

•client and server side code

Page 18: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

First GWT App

•download: code.google.com/webtoolkit/

•work through online tutorial

•mobilize

Page 19: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

generate new project

webAppCreator -out MyApp com.myco.MyApp

Page 20: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

localhost:gwt-2.0.4 joshmarinacci$ ./webAppCreator -out MyApp com.joshondesign.myapp.MyAppNot creating tests because -junit argument was not specified.Created directory MyApp/srcCreated directory MyApp/warCreated directory MyApp/war/WEB-INFCreated directory MyApp/war/WEB-INF/libCreated directory MyApp/src/com/joshondesign/myappCreated directory MyApp/src/com/joshondesign/myapp/clientCreated directory MyApp/src/com/joshondesign/myapp/serverCreated directory MyApp/src/com/joshondesign/myapp/sharedCreated directory MyApp/test/com/joshondesign/myappCreated directory MyApp/test/com/joshondesign/myapp/clientCreated file MyApp/src/com/joshondesign/myapp/MyApp.gwt.xmlCreated file MyApp/war/MyApp.htmlCreated file MyApp/war/MyApp.cssCreated file MyApp/war/WEB-INF/web.xmlCreated file MyApp/src/com/joshondesign/myapp/client/MyApp.javaCreated file MyApp/src/com/joshondesign/myapp/client/GreetingService.javaCreated file MyApp/src/com/joshondesign/myapp/client/GreetingServiceAsync.javaCreated file MyApp/src/com/joshondesign/myapp/server/GreetingServiceImpl.javaCreated file MyApp/src/com/joshondesign/myapp/shared/FieldVerifier.javaCreated file MyApp/build.xmlCreated file MyApp/README.txtCreated file MyApp/.projectCreated file MyApp/.classpathCreated file MyApp/MyApp.launchCreated file MyApp/war/WEB-INF/lib/gwt-servlet.jarlocalhost:gwt-2.0.4 joshmarinacci$

Page 21: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

GWT App Structure•client/

•GUI code, define services & proxies

•server/

•implement services

•shared/

•common code

Page 22: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

build

•run ant

•gwtc will compile your app to javascript

•generates permutations & war

•run in appserver

Page 23: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

[demo]

Page 24: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Web Technology: Browser Page or

App?•Browser: always remote

•easy deployment

•100% connection required

•App: always local

•loads faster, easy to launch

•have to submit to app catalog

Page 25: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

What is PhoneGap?

•packages HTML into native apps

•iPhone -> generate ObjC wrapper -> app

•Android -> generate Java wrapper -> app

•webOS -> app

Page 26: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Build a Mobile App

•Turn the client code into an app

•Don’t use server code OR put server side code on a real server

•Generate native projects with Phone Gap

•Compile and submit for each platform

Page 27: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

GWT + PhoneGap

• create phonegap dir

• copy phonegap-palm

• copy /war/myapp/ to framework/www/myapp/

• copy /war/MyApp.html to framework/www/index.html

• package, install, and run webOS app

• repeat for other platforms

Page 28: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

[demo]

Page 29: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Mobilize your App

Page 30: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Customizing for Mobile

•improve your UI design for tapping

•shrink everything with CSS

•support multiple resolutions

•hook into device APIs

•use HTML Canvas

Page 31: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

UI Styling with CSS

•[example]

•[master detail app with transitions]

Page 32: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Device Sizes

•media-queries

•[show same app on phone and touchpad]

Page 33: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Device Access: Camera

•[example]

•[simple app to take a picture, show it, then upload it to twitpic]

Page 34: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

HTML Canvas

•2D drawing api in HTML

•direct GWT support

•good for games and graphics

Page 35: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Canvas

•[demo of doing some charts]

Page 36: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

GWT Play

•[demo]

Page 37: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Tools

•code.google.com/p/gwt-mobile-webkit/

•github.com/dennisjzh/GwtMobile-PhoneGap

•Chrome w/ Developer Tools

Page 38: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

developer.palm.com

•100% free:

•docs & forums

•tools & sdk

•app submission

•Use any tools or language you want!

Page 39: Java Mobile Apps with GWT & PhoneGap Josh Marinacci, webOS Developer Advocate.

Questions?

[email protected]

•JoshOnDesign.com

•@joshmarinacci

•Developer.Palm.Com

•Come by the HP Booth!