17

Click here to load reader

Synapse india mobile apps update

Embed Size (px)

Citation preview

Page 1: Synapse india mobile apps update

Synapse India iPhone and Android OS

Apps Development for the iPhone and the Android

OS

Page 2: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update
Page 14: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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: Synapse india mobile apps update

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