Module 2 Introduction to Android OS.pdf
Document Details
Uploaded by Deleted User
Tags
Full Transcript
Mobile Application Design and development 1 [Introduction to Android Operating Systems] Module 1: Introduction to Android Operating...
Mobile Application Design and development 1 [Introduction to Android Operating Systems] Module 1: Introduction to Android Operating Systems Course Learning Outcomes: 1. Mobile Operating System 2. History of Android 3. What is Android 4. Features of android 5. What Android Isn’t 6. Android Native Applications 7. What does it have that others don’t? 8. What makes an Android Application 9. Fundamentals of Android Deisgn 10. The android widgets Mobile Operating System A mobile operating system, also called a mobile OS, is an operating system that is specifically designed to run on mobile devices such as mobile phones, smartphones, PDAs, tablet computers and other handheld devices some examples are Mobile OS Symbian iPhone RIM's BlackBerry Window mobile Linux Android Course Module History of Android Android, Inc. was founded in Palo Alto, California, United States in October, 2003 by Andy Rubin, Rich Miner. Google acquired Android Inc. in August, 2005, making Android Inc. a wholly-owned subsidiary of Google Inc. Google Open Handset Alliance (OHA) o The first truly open and comprehensive platform for mobile devices, all of the software to run a mobile phone but without the proprietary obstacles that have hindered mobile innovation. Utilizes the following: o Linux OS kernel o Java Programming Language o Open source libraries: SQLite, WebKit, OpenGL The following table shows the versions of Android: Platform API level Year Android 1.5 (Cupcake) 3 April 30, 2009 Android 1.6 (Donut) 4 Sept. 15, 2009 Android 2.1 (Eclair) 7 Oct. 26, 2009 Android 2.2 (Froyo) 8 Jan. 10, 2010 Android 2.3 9/10 Dec. 6, 2010 (Gingerbread) Android 3.0 11 2011 (Honeycomb) Android 4.0 (Ice Cream 14-15 October 18,2011 Sandwich) Android 4.3 (Jellybean) 16-18 July 9,2012 Android 4.4 (Kit Kat) 19-20 October 31, 2013 Android 5.0 (Lollipop) 21-22 November 12, 2014 Android 6.0 (Marsh 23 October 5,2015 Mobile Application Design and development 3 [Introduction to Android Operating Systems] Mallow) Android 7.0 (Nougat) 24-25 August 22,2016 Android 8.0 (Orep) 26-27 August 21, 2017 Android 9.0 (Pie) 28 August 6, 2018 What is Android Software stack for mobile device (Operating system(0.S), Middleware, and key application) Android O.S. is based on Linux kernel Large community of developers writing application (also known as “apps”) The Android open-source software stack consists of Java applications running on a Java- based, object-oriented application framework Each version is developed under a code name based on a dessert item. The code names are in alphabetical order, as seen by Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, and the future version, Ice Cream. One benefit is it is “cheap and easy” as a mobile development methodology. The Android SDK and tools are freely available on the Android developer website, http://developer.android.com Why Android? A simple and powerful SDK No licensing, distribution, or development fees Development over many platform which include but not limited to Linux, Mac OS, Windows Excellent documentation Thriving developer community Highly customizable and therefore can be altered to fit your tastes and needs Android automatically backs up your contacts for you Course Module Features of android Application framework enabling reuse and replacement of components. Dalvik Debug Monitoring Service (DDMS) Monitor and Control the Dalvik Virtual Machine which is optimized for mobile devices Logcat (see logged msgs) Integrated browser based on the open source WebKit engine Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional) SQLite for structured data storage Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) GSM Telephony (hardware dependent) Bluetooth, EDGE, 3G, and Wi-Fi (hardware dependent) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plug-in for the Eclipse IDE Mobile Application Design and development 5 [Introduction to Android Operating Systems] What Android Isn’t As a disruptive addition to a mature field, it’s not hard to see why there has been some confusion about what exactly Android is. Android is not: ❑ A Java ME implementation. Android applications are written using the Java language, but they are not run within a Java ME virtual machine, and Java-compiled classes and executables will not run natively in Android. ❑ Part of the Linux Phone Standards Forum (LiPS) or the Open Mobile Alliance (OMA). Android runs on an open source Linux kernel, but, while their goals are similar, Android’s complete software stack approach goes further than the focus of these standards-defining organizations. ❑ Simply an application layer. While it does include an application layer, “Android” also describes the entire software stack encompassing the underlying operating system, API libraries, and the applications themselves. ❑ A mobile phone handset. Android includes a reference design for mobile handset manufacturers, but unlike the iPhone, there is no single “Android Phone.” Instead, Android has been designed to support many alternative hardware devices. ❑ Google’s answer to the iPhone. The iPhone is a fully proprietary hardware and software platform released by a single company (Apple), while Android is an open source software stack produced and supported by the Open Handset Alliance and designed to operate on any handset that meets the requirements. There’s been a lot of speculation regarding a Google-branded Android phone, but even should Google produce one, it will be just one company’s hardware implementation of the Android platform. Course Module Android Native Applications Android phones will normally come with a suite of preinstalled applications including, but not limited to: ❑ An e-mail client compatible with Gmail but not limited to It ❑ An SMS management application ❑ A full PIM (personal information management) suite including a calendar and contacts list, both tightly integrated with Google’s online services ❑ A fully featured mobile Google Maps application including StreetView, business finder, driving directions, satellite view, and traffic conditions ❑ A WebKit-based web browser ❑ An Instant Messaging Client ❑ A music player and picture viewer ❑ The Android Marketplace client for downloading third-party Android applications. ❑ The Amazon MP3 store client for purchasing DRM free music. What does it have that others don’t? Many of the features listed previously, such as 3D graphics and native database support, are also available in other mobile SDKs. Here are some of the unique features that set Android apart: ❑ Google Map Applications. Google Maps for Mobile has been hugely popular, and Android offers a Google Map as an atomic, reusable control for use in your applications. The MapView widget lets you display, manipulate, and annotate a Google Map within your Activities to build map-based applications using the familiar Google Maps interface. ❑ Background Services and Applications. Background services let you create applications that use an event-driven model, working silently while other applications are being used or while your mobile sits ignored until it rings, flashes, or vibrates to get your attention. Maybe it’s an application that tracks the stock market, alerting you to significant changes in your portfolio, or a Mobile Application Design and development 7 [Introduction to Android Operating Systems] service that changes your ring tone or volume depending on your current location, the time of day, and the identity of the caller. ❑ Shared Data and Interprocess Communication. Using Intents and Content Providers, Android lets your applications exchange messages, perform processing, and share data. You can also use these mechanisms to leverage the data and functionality provided by the native Android applications. To mitigate the risks of such an open strategy, each application’s process, data storage, and files are private unless explicitly shared with other applications using a full permission-based security mechanism. ❑ All Applications Are Created Equal. Android doesn’t differentiate between native applications and those developed by third parties. This gives consumers unprecedented power to change the look and feel of their devices by letting them completely replace every native application with a third-party alternative that has access to the same underlying data and hardware. Every rule needs an exception and this one has two. The “unlock” and “in-call experience” screens cannot be replaced in the initial SDK release. ❑ P2P Inter-Device Application Messaging. Android offers peer-to-peer messaging that supports presence, instant messaging, and inter-device and or inter-application communication. What makes an Android Application Android applications consist of loosely coupled components, bound using a project manifest that describes each component and how they interact. There are six components that provide the building blocks for your applications: ❑ Activities Your application’s presentation layer. Every screen in your application will be an extension of the Activity class. Activities use Views to form graphical user interfaces that display Course Module information and respond to user actions. In terms of desktop development, an Activity is equivalent to a Form. ❑ Services The invisible workers of your application. Service components run invisibly, updating your data sources and visible Activities and triggering Notifications. They’re used to perform regular processing that needs to continue even when your application’s Activities aren’t active or visible. ❑ Content Providers A shareable data store. Content Providers are used to manage and share application databases. Content Providers are the preferred way of sharing data across application boundaries. This means that you can confi gure your own Content Providers to permit access from other applications and use Content Providers exposed by others to access their stored data. Android devices include several native Content Providers that expose useful databases like contact information. ❑ Intents A simple message-passing framework. Using Intents, you can broadcast messages system-wide or to a target Activity or Service, stating your intention to have an action performed. The system will then determine the target(s) that will perform any actions as appropriate. ❑ Broadcast Receivers Intent broadcast consumers. By creating and registering a Broadcast Receiver, your application can listen for broadcast Intents that match specifi c fi lter criteria. Broadcast Receivers will automatically start your application to respond to an incoming Intent, making them ideal for event-driven applications. ❑ Notifications A user notifi cation framework. Notifi cations let you signal users without stealing focus or interrupting their current Activities. They’re the preferred technique for getting a user’s attention from within a Service or Broadcast Receiver. For example, when a device receives a text message or an incoming call, it alerts you by flashing lights, making sounds, displaying icons, or showing dialog messages. You can trigger these same events from your own applications using Notifi cations. By decoupling the dependencies between application components, you can share and interchange individual pieces, such as Content Providers or Services, with other applications — both your own and those of third parties. Mobile Application Design and development 9 [Introduction to Android Operating Systems] Fundamentals of Android Deisgn User Interface design, human–computer interaction, and usability are huge topics that aren’t covered in great depth in this book. Nonetheless, it’s important that you get them right when creating your User Interfaces. Android introduces some new terminology for familiar programming metaphors, which include: ❑ Views Views are the basic User Interface class for visual interface elements (commonly known as controls or widgets). All User Interface controls, and the layout classes, are derived from Views. ❑ View Groups View Groups are extensions of the View class that can contain multiple child Views. By extending the ViewGroup class, you can create compound controls that are made up of interconnected child Views. The ViewGroup class is also extended to provide the layout managers, such as LinearLayout, that help you compose User Interfaces. ❑ Activities Activities, described in detail in the previous chapter, represent the window or screen being displayed to the user. Activities are the Android equivalent of a Form. To display a User Interface, you assign a View or layout to an Activity. Android provides several common UI controls, widgets, and layout managers. For most graphical applications, it’s likely that you’ll need to extend and modify these standard controls — or create composite or entirely new controls — to provide your own functionality. The android Widgets Android supplies a toolbox of standard Views to help you create simple interfaces. By using these controls (and modifying or extending them as necessary), you can simplify your development and provide consistency between applications. Course Module The following list highlights some of the more familiar toolbox controls: ❑ TextView A standard read only text label. It supports multiline display, string formatting, and automatic word wrapping. ❑ EditText An editable text entry box. It accepts multiline entry and word wrapping. ❑ ListView A View Group that creates and manages a group of Views used to display the items in a List. The standard ListView displays the string value of an array of objects using a Text View for each item. ❑ Spinner Composite control that displays a TextView and an associated ListView that lets you select an item from a list to display in the textbox. It’s made from a Text View displaying the current selection, combined with a button that displays a selection dialog when pressed. ❑ Button Standard push-button ❑ CheckBox Two-state button represented with a checked or unchecked box ❑ RadioButton Two-state grouped buttons. Presents the user with a number of binary options of which only one can be selected at a time. This is only a selection of the widgets available. Android also supports several more advanced View implementations including date-time pickers, auto-complete input boxes, maps, galleries, and tab sheets. For a more comprehensive list of the available widgets, head to http://code.google.com/android/reference/view-gallery.html. Mobile Application Design and development 11 [Introduction to Android Operating Systems] TextView and EditText A TextView, as shown in the line “This is some text” in the above figure, is just what you’d expect: a place to display a text string. The vanilla TextView is for display only, whereas EditText is a predefined subclass of TextView that includes rich editing capabilities. Each TextView has the attributes you’d expect of such a component: you can change its height, width, font, text color, background color, and so forth. TextViews also have some useful unique attributes: autoLink If set (true), finds URLs in the displayed text and automatically converts them to clickable links. autoText If set (true), finds and corrects simple spelling errors in the text. editable If set (true), indicates that the program has defined an input method to receive input text (default is false for TextView, and true for EditText). inputMethod Identifies the input method (EditText defines one for generic text). The next example shows how to use a TextView and an EditText with Buttons. It also shows the XML layout file (main.xml), which uses pretty standard and recommended layout parameters. Example 2-1. Layout file for TextView and EditView example Course Module Example 2-2 contains the accompanying Java source. Example 11-2. Java for TextView and EditView: TextViewDemo.java package com.android.demo; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; public class TextViewDemo extends Activity { private static TextView txt1; private static EditText etxt1; private static Button btn1; // Create a button click listener for the Done button. private final Button.OnClickListener btnDoneOnClick = new Button.OnClickListener() { public void onClick(View v) { String input = etxt1.getText().toString(); //Display to TextView the input Mobile Application Design and development 13 [Introduction to Android Operating Systems] txt1.setText(input); etxt1.setText(""); } }; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); //Get pointers to the Views defined in main.xml txt1 = (TextView) findViewById(R.id.txtDemo); etxt1 = (EditText) findViewById(R.id.eTxtDemo); btn1 = (Button) findViewById(R.id.btnDone); //Set the string displayed in TextView1 txt1.setText("This is some text."); //Set the OnClickListener for the Done button btn1.setOnClickListener(btnDoneOnClick); } } Here are some of the highlights of the code: 1. Defines a ClickListener that we’ll attach to the “Log it” Button. 2. Because onCreate is executed just once, as soon as Android instantiates this View, we put all the configuration we need here. Course Module 3. Loads the XML layout file for the application by setting the ContentView to main.xml. 4. Finds the Views that are defined in main.xml. 5. Puts an initial string into the TextView. 6. Connects the Button with the ClickListener. Now the user can enter and edit text in the EditText, and when he clicks on “Log it”, the OnClickListener is called and the text is written to the logcat log. The string in the EditText is cleared out, and the widget is ready for another entry. References and Supplementary Materials Online Supplementary Reading Materials https://www.javaworld.com/article/3095406/android-studio-for-beginners-part-1- installation-and-setup.html Online Instructional Videos 1. ; ; (Online instructional videos should come from sources that are not within the domain of “.com”. In cases when videos are only available within the “.com” domain, it is expected that 2 back-up links will be provided.)