Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer...
-
Upload
bennett-harper -
Category
Documents
-
view
216 -
download
0
Transcript of Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer...
![Page 1: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/1.jpg)
Introduction to Apps Development for the iPhone and
the Android OSArt Gittleman
Professor, Computer ScienceCalif State Univ Long Beach
Feb 28, 2011
![Page 2: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/2.jpg)
Android
• Need Java 5.0+• Easiest to use Eclipse 3.3.1+• Download SDK starter pack from developer.android.com and invoke SDK setup program• Install Eclipse plugin Help, Install New Software Android Development Tools• Tell Eclipse where Android is located• Windows, Preferences, Android
![Page 3: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/3.jpg)
Hello Android
Eclipse File, New, Project, Android, Android ProjectCreate Android Virtual Device (AVD) Window, Android SDK, AVD ManagerRun (on emulator)To run on phone enable USB debugging Settings, Applications, USB Debugging Install USB driver (Windows only)
![Page 4: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/4.jpg)
Android App Framework
Created by default
• src -- Hello.java -- main Activity
• res, drawable -- icon.png – app’s icon
• res, values -- strings.xml – constants
• res, layout – main.xml -- screen layout
• AndroidManifest.xml – table of contents
• gen – R.java – references, never touch it
![Page 5: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/5.jpg)
Rock Paper Scissors
• Two activities – Rsp and Res• Layout – TextView over nested layout• Hook up buttons• Use an Intent to go from one to the other• Result activity – text, text, button Result text enhanced• Can configure layouts by dragging widgets
and entering properties
![Page 6: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/6.jpg)
Ball Game
• Touch ball to score, after 10 ball shrinks and goes faster
• Easy, medium, hard choices
• Uses a Java view not XML
• Uses the onTouchEvent handler
• Use the onDraw method to draw on a canvas
![Page 7: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/7.jpg)
OpenGL (from Hello Android)
• Rotating cube
• Uses OpenGL ES (embedded systems)
• Draws cube from vertices
• Uses GLRenderer
onSurfaceCreated -- set properties
onSurfaceChanged – update view
onDrawFrame – draw the scene
![Page 8: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/8.jpg)
Browser View (from Hello Android)
• An EditText and Button above WebView
• WebView uses loadUrl method to display web page
• Documentation – developer.android.com
![Page 9: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/9.jpg)
iPhone
• Needs Intel Mac, OS X 10.5.4+
• Download SDK and register (free) developer.apple.com/iphone
• $99 to deploy to iPhone or iPod
• Uses Objective-C
• Launch XCode
• Examples from iPhone SDK Development
![Page 10: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/10.jpg)
Hello iPhone
• File, New Project in XCode• Choose View-based Application• HelloViewController class and
HelloViewController.xib (nib), freeze-dried GUI
• HelloAppDelegate manages application• Use Interface Builder to add Label and
configure color and size in Attributes inspector
![Page 11: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/11.jpg)
Hello User
• Allow user to enter a name• IBOutlet – reference from code to nib
object, e.g. label, text field• IBAction – method nib’s objects can call,
e.g. button press handler• In Interface Builder, connect outlets to
code, connect action Touch Up Inside event to handler method, sayHello
• Implement the sayHello handler method
![Page 12: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/12.jpg)
Movie - MVC
• Create Movie class (the model)
• Labels with movie info, Edit button
• MovieEditorViewController for edit view with Done button to return to main screen
• Send message in Edit button to start movie controller
• Send message in Done button to return to MovieViewController
![Page 13: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/13.jpg)
![Page 14: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/14.jpg)
Movie Table
• UITableView, UITableViewDataSource protocol provides number of rows, add, delete, etc., UITableViewDelegate to handle tapping to select a row
• Uses Navigation-based Application
UINavigationController
UINavigationBar (with Edit and Add buttons)
RootViewContoller (with UITableView)
UINavigationItem
![Page 15: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/15.jpg)
Movie Table -2
• UINavigationController maintains navigation state as a stack of view controllers.
• Uses an array to hold table data. Initial array hard-coded. Changes are not saved.
![Page 16: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/16.jpg)
Conference -- Core Data
• Built on SQLite
• Managed Object Context – row data turned into objects
• Managed Object Model – like schema
• Persistence Store Coordinator – connects to the database
• Double-click on Conference.xcdatamodel to get screen to configure tables
![Page 17: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/17.jpg)
Core Data - 2
• Create Managed Object Class to represent the model
• Conference has tracks with trackAbstract, name, sessions
• Edit and Add buttons configured in code in viewDidLoad method rather than in Interface Builder
• NSFetchedResultsController – adaptor between CoreData and table view
![Page 18: Introduction to Apps Development for the iPhone and the Android OS Art Gittleman Professor, Computer Science Calif State Univ Long Beach Feb 28, 2011.](https://reader035.fdocuments.us/reader035/viewer/2022072115/56649d9d5503460f94a86b2b/html5/thumbnails/18.jpg)
References
• Hello Android, Third Edition, Ed Burnette, Pragmatic Programmers, 2010.
• Introduction to Android development Using Eclipse and Android widgets
• ibm.com/developerWorks• iPhone SDK Development, Bill Dudney and
Chris Adamson, Pragmatic Programmers, 2009.• Beginning iPhone Games Development, PJ
Cabrera, et al, Apress, 2010.• Developing Apps for iOS (video and pdf) from
Stanford University