Peter Wolf (Application architect)
Platform Architecutre
- Linux Kernel
- threading, low-level memory management, drivers, security features (permissions, process isolation, IPC), application sandbox, system partition, netwroking
- Hardware Abstration Layer
- gigher level Java API framework fod device hardware (camera, Bluetooth, ...)
- Android Runtime
- virtual machine(s), AOT & JIT compilation, GC, debugging, profilling, diagnostic, crash reporting
- Native C/C++ Libraries
- application building blocks
- System apps
- default apps can be replaced
Application Components
- Intents & Intent Filters
- to start an activity, to start a service, to deliver a broadcast
- Activities
- a screen with which users can interact; has a window to draw its interface – typically full screen
- Services
- Content Providers
- Application Widgets
Activities
- Main activity – started by launcher, defined by intent filter
- Within a task activities are contained in back stack
- User interface = hierarchy of views
- Layout = android.view.ViewGroup
- linear, grid, relative
- onCreate
- create views, bind data, restore state
- onResume
- in foreground, user input
- onPause
- commit unsaved changes, stop animations
Saving Activity State
- onSaveInstanceState
- default implementation does some job, use only for state of the UI, not to persist data
- onRestoreInstanceState
Services
- Invoked via Intents
- Started Service
- startService(), usually single operation, returns no results, stops itself in the end (by calling stopSelf()), can be stopped from outside by calling stopService(), i.e. upload/download file
- Bound Service
- bindService(), client-server interface, runs while it is bound, stops when all components unbind it (by calling unbindService())
- Notifications to user via toasts or status bar
Content Providers
- Manage access to structured data
- Access via android.content.ContentResolver
- Share data with other applications
- Provide custom search suggestions
- Defined by URI
- content://user_dictionary/words
- API to retrieve data
- API to insert, update, or delete data
- Custom APIs
Application Widgets
- Mini application views that can be embedded in other application (home screen)
User Interface
- Composed of Views and ViewGroups
- Forms layout
- Standard controls
- Input controls
- button, text field, checkbox, radio button, toggle button, picker, spinner
- Input events (gestures)
- click, long click, focus change, touch, context menu
- Menus
- Settings
- Dialogs
- Notifications
- Search
- Input controls
- Custom components
Best Practices
- Support multiple screens
- Support tablets and handsets
- Material Design