Developer's overview and comparison of the iPhone and the ...


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Developer's overview and comparison of the iPhone and the ...

  1. 1. iPhone Developer’s overview and comparison of the iPhone and the Android platforms Erlend Stav SINTEF ICT June 2009 ICT 1
  2. 2. Overview iPhone Vendors and licensing Application distribution Platform architecture Application architecture GUI and other components Inter-app communication Development tools ICT 2
  3. 3. Devices, licensing , and openness iPhone Apple is the only device vendor Open Handset Alliance Device OS is not open source Devices from multiple vendors, including HTC, Samsung, Sony iPhone Developer Program Ericsson, Motorola, Acer, … membership has an annual fee Free and open source mobile ($99 to $299) platform, including OS, Regular iPhone and iPod Touch middleware and key retail devices are used for applications development, but each device Regular retail devices can be must first be registered by the used to test and use developer under the iPhone applications Developer Programme Android Dev Phone 1, SIM- unlocked and hardware- unlocked development device, but is currently only ship to 18 countries worldwide. ICT 3
  4. 4. Distributing your applications iPhone iPhone Developer Programme Developers can publish their members can sell or provide applications through Android their applications for free Market through App Store To become a publisher of applications in the Android Market Applications have to be requires registration and a fee approved by Apple before the ($25) become available in App Store Currently only developers from 7 With the Store Kit API countries can sell applications developers can integrate Currently free applications can be purchase of new content and distributed to 24 countries, and paid application extensions into their applications to 9 countries applications In-house distribution available for enterprises with 500+ employees ICT 4
  5. 5. Acquiring and deploying applications iPhone Applications are acquired by Applications can be acquired by users through Apple’s official users through Android Market App Store (both free and paid) Applications are acquired Applications are acquired directly from Android Market to directly from AppStore to the the device. Currently Market is device, or using AppStore from not viewable outside the device. iTunes on PC / Mac and then All code for an application is synchronizing the device bundled as an Android package Updates to installed for distribution and deployment applications are visible when Updates to installed visiting AppStore or using applications are available when iTunes, and selected updates visiting My Downloads under are deployed similar to new Android Market. applications ICT 5
  6. 6. iPhone Architecture Overview •UI Kit •In App Email Cocoa •Map Kit Framework •Address Book UI Touch •Apple Push Notification Service •2D Graphics (incl. PDF) •Audio Media •Animation •OpenAL •OpenGL ES (2D & 3D) •Media Player Framework •Foundation •Core Location Core •SQLite and XML support •Address Book Services •Core Data •In App Purchase •CFNetwork •System Core •Accessory support •Security OS ICT
  7. 7. Architecture overview Source: ICT
  8. 8. Runtime model / processes for application iPhone Single 3rd party application Full multitasking running Default: every application has Design rule: fast launch and fast separate Linux process shutdown, store state to allow Each process has its own Java users to continue where they VM left To conserve resources it is Application launch image – possible to allow applications to gives user impression of quick run in the same process, launch sharing the same VM This Apple video includes an These YouTube videos shows example of the basic interaction how home screen and home (time interval 1:12-1:22) button is used to switch between applications ICT 8
  9. 9. Application Architecture No main() function for Activity: presents user interface applications Service: Four kinds of components, runs in background without an application may have user interface multiple of each. Broadcast receivers: only receives and reacts to broadcast announcements Content providers: makes set of application data available to other applications ICT 9
  10. 10. Activities, tasks, intents A task is a group of Activities, services and activities arranged as a broadcast receivers are stack (seen from the user activated through as an application) asynchronous messages One activity can start called intents other activities An intent names an action Activities from different and a data URI applications can part of Intents supported by the same task (but belong components are declared to different processes) in the application's manifest See this YouTube video for illustration ICT 10
  11. 11. Lifecycle of activities Source: ICT 11
  12. 12. User interfaces Views are basic units of UI, view groups View groups, such as layouts, provide hierarchy and organization such as linear, tabular, etc. Rich set of widgets (concrete views such as buttons, text view, image view, etc) Activities have a content view Source: ICT 12
  13. 13. iPhone Application architecture Applications have a main() Core data function (usually follows a Manages changes to model template) objects Allows keeping just a subset of model objects in memory Design patterns Schema describe model Model-View-Controller objects Delegation Trigger-action ICT 13
  14. 14. iPhone Application lifecycle Source: ICT 14
  15. 15. iPhone GUI Rich set of views designed for touch interface Multi-touch events View animation Source: ICT 15
  16. 16. iPhone Tab Bar GUI and controllers Source: ICT 16
  17. 17. iPhone Navigation GUI Source: ICT 17
  18. 18. High level components iPhone Map component (based on Map View (as add-on), supports Google Maps), can add overlays annotations Web View HTML-viewer (including HTML, Video View CSS and JavaScript content) Media Controller Contact / mail Music In addition activities from other Photo library applications are integrated Camera – standard UI for taking through intents pictures ICT 18
  19. 19. Inter-application communication iPhone Launch other application using Launch other activities using an URL to communicate with it intents with action and URI Application can register custom Components register intent URL schemes filters they react to Copy / paste between Copy / paste between applications applications Content Providers gives access to data from other applications Components can bind to services also of other applications, and perform remote procedure calls to interfaces declared using an IDL ICT 19
  20. 20. Examples of URLs and intent actions iPhone m ACTION_SEND tel:1-408-555-5555 CALL tel:2125551212 sms:1-408-555-1212 ACTION_EDIT content://contacts/1 aps?daddr=San+Francisc VIEW http://web_address o,+CA&saddr=cupertino VIEW (Driving directions geo:0,0?q=my+street+add between San Francisco ress and Cupertino) ACTION_GET_CONTENT ACTION_REBOOT ICT 20
  21. 21. Device access iPhone Accelerometer Sensors including Shake events accelerometer, proximity, light, temperature, … Positioning (GPS) Positioning, location provides, Camera GPS status External accessories / BT Camera including settings, Made for iPod licensing preview, snap picture program Currently no Bluetooth API API for accessing current state and listening to state changes for in telephone (network type, cell ids, calls, data traffic…) ICT 21
  22. 22. File management iPhone Sandbox Default: each application Each application has its has a unique Linux user own home directory id, and application files are Backup: automatic when only visible to that user id synched using iTunes, all of home directory except cache and tmp directory ICT 22
  23. 23. Programming languages iPhone C and Objective C All applications are Compiled to native code developed in Andoid’s No garbage collection, but Java uses reference counters Dalvik VM specific to and reference pools. Android No (official) Java version Android-specific bytecode optimized for minimal memory footprint Libraries do not match any of the standard Java profiles, but covers most of J2ME CDC ICT 23
  24. 24. #import <UIKit/UIKit.h> iPhone @interface MyViewController : UIViewController <UITextFieldDelegate> { UITextField *textField; UILabel *label; Objective C NSString *string; code } @property (nonatomic, retain) IBOutlet UITextField *textField; Example @property (nonatomic, retain) IBOutlet UILabel *label; @property (nonatomic, copy) NSString *string; - (IBAction)changeGreeting:(id)sender; @end Header file and implementation - (IBAction)changeGreeting:(id)sender { self.string = textField.text; of one method NSString *nameString = string; if ([nameString length] == 0) { nameString = @"World"; } NSString *greeting = [[NSString alloc] initWithFormat:@"Hello, %@!", nameString]; label.text = greeting; [greeting release]; } Source: ICT 24
  25. 25. Development tools and profiling iPhone Development requires a Free SDK available for Mac Windows, Mac, and Linux development Any Java development environment can be used Free tools include: Free tools include: XCode IDE Android Development Tools plugin for Eclipse iPhone emulator Android Emulator Instruments (for profiling) Memory and performance Interface Builder profiling Debugging tools UI stress-test tools ICT 25
  26. 26. iPhone XCode IDE Source: ICT
  27. 27. iPhone Interface Builder Used to compose the User interface and main object instances of the iPhone application Source: ICT
  28. 28. iPhone Interface Builder can connect Events to receiving objects Source: ICT
  29. 29. iPhone In this example the changeGreeting: method of File’s Owner is triggered by “touch up inside” for the Hello button Source: Source: ICT
  30. 30. References iPhone Apple’s iPhone Dev Center Site: Illustrations from: iPhone Application Programming Guide View Controller Programming Guide for iPhone OS Your First iPhone Application Android’s developer guide Site: Illustrations from: What is Android? Application Fundamentals User Interface – Declaring Layouts ICT 30