2. Android Architecture Stack and Introduction to UI
Core libraries provide?
most of the functionality available in the core libraries of the Java language with APIs such as: Data Structures, Utilities, File Access, Network Access and Graphics
In Android we have 3 ways to define the Views:
● Android Studio layout editor: visual representation of XML ● XML editor ● Java code
Package manager
- installs/removes applications - track of app packages, data sharing +services
Native libraries include:
Graphics (Surface Manager, 2/3D) Multimedia (Media Framework) Database DBMS (SQLite) Font Management (FreeType) WebKit C libraries (Bionic)
Notification Manager:
- Alerts the user about occurring important events. - Enabling all applications to display custom alerts in the status bar, flashing lights, vibrations etc.
Location Manager:
- Allowing apps to receive location/movement info such as generated by GPS. - Allow context specific tasks i.e., finding direction from current location - Allow developers to tap into location based services, whether by GPS, local Wi-Fi databases, or cell towers. - Uses GPS - most accurate, slow battery drain, and primarily for outdoor use.
Why do we need the Hardware abstraction layer?
- Android application/framework does not communicate with underlying hardware using system calls. instead, it uses Java API - Linux can only handle system calls - so we need glue layer between android framework and linux system.
How to make an APK file?
- a program for Android is first compiled - Then all of its parts are packaged into one file. This holds all of that program's code (such as .dex files), resources, assets, certificates, and manifest file.
Activity manager
- Responsible for starting, stopping and resuming the various applications. - Manages the lifecycle of applications and providing a common navigation back stack.
What is the difference between Class hierarchy and layout hierarchy
- View class-hierarchy is standard object-oriented class inheritance.For example, Button is-a TextView is-a View is-an Object (Superclass-subclass relationship) - Layout hierarchy is how views are visually arranged.For example, LinearLayout can contain Buttons arranged in a row(Parent-child relationship)
How do put large amounts of texts such as News articles in your mobile application?
1. To scroll a TextView, embed it in a ScrollView. Only one View element (usually TextView) allowed in a ScrollView 2. To scroll multiple elements, use one ViewGroup (such as LinearLayout) within the ScrollView
Telephony manager
Allowing interaction with phone, SMS and MMS services
(blank) is the file format used to distribute and install application software and middleware onto Google's Android operating system.
Android application package file (APK)
RecyclerView
Contains a list of elements and enables scrolling by adding and removing elements dynamically
ScrollView
Contains one element and enables scrolling
Is it good to nest multiple scrolling views?
Do not nest multiple scrolling views
Content Provider
Enabling applications to access data from other applications or to share their own data. Cross apps. address book contacts.
How are libraries exposed to developers?
Exposed to developers through the Android application framework
T or F: Dalvik has been written such that a device can run one VMs efficiently
False, can run multiple VMs efficiently
T or F: Executing the Dalvik Executable (.deqs) format
False. (.dex)
T or F: There are over 1K different types of views available from the Android system, all children of the View class
False. Over 100.
ScrollView is a subclass of (blank)
FrameLayout
Android (blank) layer allows the Android application/framework to communicate with the hardware specific device drivers.
HAL
Android HAL (in abstract) bridges the gap between (blank) and (blank).
Hardware, software
Use (blank) for horizontal scrolling
HorizontalScrollView
Can you create custom views?
If necessary, create custom views by subclassing existing views or the View class
For Android application, HAL provides API's through which service can place a request to device and HAL uses functions provided by the (blank) layer Linux system to serve the request from the (blank).
Lower, android framework
Window manager
Manages the many windows comprising an app (browser-notifications, wifi , time, battery remaining, main window, sub windows)
Event handlers are?
Methods that do something in response to a click
ConstraintLayout
Positions UI elements using constraint connections to other elements and to the layout edges
View system
Provides common graphical elements (Used to build UI, including lists, grids, text boxes, buttons, and embedded web browser. Phone tab/call log tab/contact tab)
Resource Manager
Providing access to non-compiled resources (strings-eng, fr,, graphics, and layout files)
Use a (blank) for lists
RecyclerView
What are resources?
Separate static data from code in your layouts.
Resources can be?
Strings, dimensions, images, menu text, colors, styles
Surface Manager
manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications
T or F: .dex format is optimized for minimal memory footprint.
True
T or F: DVM is a Register-based virtual machine
True
T or F: Each Android application runs in its own process, with its own instance of the Dalvik VM.
True
T or F: every user interface element that you see in your mobile device is a View.
True
T or F: ScrollView is nor good for long texts and multiple layouts.
True.
What are the view subclasses?
View subclasses are basic user interface building blocks ● Display text (TextView class), edit text (EditText class) ● Buttons (Button class), menus, other controls ● Scrollable (ScrollView, RecyclerView) ● Show images (ImageView) ● Group views (ConstraintLayout and LinearLayout)
WebKit
a modern web browser engine which powers both the Android browser and an embeddable web view
SQLite
a powerful and lightweight relational database engine
3D libraries
an implementation based on OpenGL ES 1.0 APIs
How do you write a handler to view in xml layout?
android:onClick="Do_smt"
What are some of the common TextView attributes?
android:text—text to display android:textColor—color of text android:textAppearance—predefined style or theme android:textSize—text size in sp android:textStyle—normal, bold, italic, or bold|italic android:typeface—normal, sans, serif, or monospace android:lineSpacingExtra—extra space between lines in sp
FreeType
bitmap and vector font rendering
HAL is a (blank) layer which is a vendor specific implementation.
c/c++
A method, called an (blank), is triggered by a specific event and does something in response to the event
event handler
When do we use Density-independent Pixels?
for Views, when we want to define any view size or image size.
When do we use Scale-independent Pixels?
for text, when u want define the size of font or text
How do you implement a handler in java activity?
public void Do_smt (View view) { String msg = "Hello Toast!"; Toast toast = Toast.makeText(this, msg, duration); toast.show(); }
Media Libraries
support playback and recording of many popular audio and video formats, as well as image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG
System C library
the standard C system library, tuned for embedded Linux-based devices
SGL
the underlying 2D graphics engine
The core components of android applications 5. Mention them.
• Activity Manager • Window Manager • Package Manager • Telephony Manager • Location Manager
What do you know about the application layer in the android software stack?
• All application, native and user apps • All applications are written using the Java language. • Can replace built in apps
Android provides a set of core applications. Give an example of some.
• Email Client • SMS Program • Calendar • Maps • Browser • Contacts
What are the advantages of the linux kernel layer in the android software stack?
• Security (e.g. secure multi-process environment) • Power Management • Memory management • Interprocess communication • Portability (i.e. easy to compile on different hardware architectures)
What are the best practices for view heirarchies?
● Arrangement of view hierarchy affects app performance ● Use smallest number of simplest views possible ● Keep the hierarchy flat—limit nesting of views and view groups
What are some of the common layout classes?
● ConstraintLayout: Connect views with constraints ● LinearLayout: Horizontal or vertical row ● RelativeLayout: Child views relative to each other ● TableLayout: Rows and columns ● FrameLayout: Shows one child of a stack of children
How do we format texts in string resource?
● Use <b> and <i> HTML tags for bold and italics ● All other HTML tags are ignored ● String resources: one unbroken line = one paragraph ● \n starts a new a line or paragraph ● Escape apostrophes and quotes with backslash (\", \') ● Escape any non-ASCII characters with backslash (\)
What do you know about layouts?
● are specific types of ViewGroups (subclasses of ViewGroup) ● contain child views ● can be in a row, column, grid, table, absolute