🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

Android Development PPT.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Android Development Introduction 1 Chapter 1 - Goals THE BIG PICTURE 1. What is Android? 2. Overview development environment 2 Chapter 1 - Resources Android’s web page http://www.android.com/...

Android Development Introduction 1 Chapter 1 - Goals THE BIG PICTURE 1. What is Android? 2. Overview development environment 2 Chapter 1 - Resources Android’s web page http://www.android.com/ 3 What is Android? Android is an open-source software platform created by Google and the Open Handset Alliance. It is primarily used to power mobile phones. It has the capability to make inroads in many other (non-phone) embedded application markets. 4 What is Android? Android™ consists of a complete set of software components for mobile devices including: – an operating system, – middleware, and – embedded key mobile applications – a large market. 5 Why Android? Listen from the project creators/developers (2.19 min) – Nick Sears. Co-founder of Android – Steve Horowitz. Engineering Director – Dam Morrill. Developer – Peisun Wu. Engineering Project Manager – Erick Tseng. Project Manager – Iliyan Malchev. Engineer – Mike Cleron. Software Manager – Per Gustafsson. Graphics Designer. – etc… http://www.youtube.com/watch?v=6rYozIZOgDk&eurl=http://www.android.com/about/&feature=player_embedd ed You will hear statements such as “…currently it is too difficult to make new products … open software brings more innovation … choices … lower costs … more applications such as family planner, my taxes, understand my wife better, … ” 6 What is Open Handset Alliance? Quoting from www.OpenHandsetAlliance.com page “… Open Handset Alliance™, a group of 47 technology and mobile companies have come together to accelerate innovation in mobile and offer consumers a richer, less expensive, and better mobile experience. Together we have developed Android™, the first complete, open, and free mobile platform. We are committed to commercially deploy handsets and services using the Android Platform. “ 7 Open Handset Alliance Members Operators Software Co. Commercializat. Semiconductor Handset Manf China Mobile Ascender Corp. Aplix Audience ACER China Unicom eBay Noser Engineering Broadcom Corp. ASUS KDDI Corp. Esmertec Astonishing Tribe Intel Corp. HTC NTT DoCoMo Google Wind River Systems Marvell Tech. LG Sprint Nextel LivingImage Omron Software Group Motorola T- Mobile NMS Comm. … Nvidia Corp. Samsung Telecom Italia Nuance Comm. Teleca Qualcomm ASUSTek Telefónica PacketVideo SiRF Tech. Holdings Garmin Vodafone SkyPop Synaptics Huawei Tech Softbank SONiVOX Texas Instr. LG … … AKM Semicond. Samsung Ericsson Borqs ARM … Atheros Comm Sony Ericsson... Toshiba EMP 8 See Android Developers http://www.youtube.com/watch?v=7Y4thikv-OM Short video (4 min.) Showing Dave Bort and Dan Borstein, two members of the Android Open Source Project talk about the project. 9 The Android Platform Again, what did they say about Android? Android is a software environment built for mobile devices. It is not a hardware platform. Android includes: Linux kernel-based OS, a rich UI, telephone functionality, end-user applications, code libraries, application frameworks, multimedia support,... User applications are built for Android in Java. 10 Android’s Context: Mobile Market Player$ Stakeholders: Mobile network operators want Operators to lock down their networks, controlling and metering traffic. Device manufacturers want to differentiate themselves with features, reliability, and price Device Software points. Manufacturers Vendors Software vendors want complete access to the hardware to deliver cutting-edge applications. 11 The Maturing Mobile Experience Electronic tools of a typical business warrior Not so long ago … Today 1. Phone 1. Smartphone 2. Pager 2. Laptop (perhaps!) 3. PDA Organizer 4. Laptop 5. Portable music player 6. No Internet access / limited access Tomorrow ? 12 MOBILE OPERATING SYSTEMS A mobile operating system (OS) is software that allows smartphones, tablet PCs and other devices to run applications and programs. A mobile OS typically starts up when a device powers on, presenting a screen with icons or tiles that present information and provide application access. Mobile operating systems also manage cellular and wireless network connectivity, as well as phone access.. 13 MOBILE OPERATING SYSTEMS Example of Mobile OS Symbian iPhoneOS (IOS) RIM's BlackBerry Window mobile Linux PalmwebOS Android. 14 HISTORY OF ANDROID OS 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) 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.. 15 HISTORY OF ANDROID OS cont. Utilizes the following: Linux OS kernel Java Programming Language Open source libraries: SQLite, WebKit, OpenGL. 16 HISTORY OF ANDROID OS cont. In Android, all applications have equal standing. Third-party and native Android applications are written using the same APIs and are executed on the same run time. Users can remove and replace any native application with a third-party developer alternative; even the dialer and home screens can be replaced.. 17 HISTORY OF ANDROID OS cont. The Open Handset Alliance Google and 33 other companies announced the formation of the Open Handset Alliance on November 5, 2007. According to the joint press release from that day: This alliance shares a common goal of fostering innovation on mobile devices and giving consumers a far better user experience than much of what is available on today’s mobile platforms. By providing developers a new level of openness that enables them to work more collaboratively, Android will accelerate the pace at which new and compelling mobile services are made available to consumers.. 18 HISTORY OF ANDROID OS cont. For mobile application developers, that means they are free to develop whatever creative mobile applications they can think of, free to market them (or give them, at their option) to Android mobile phone owners, and free to profit from that effort any way they can. Each member of the Open Handset Alliance has its own reasons for participating and contributing its intellectual property, and they are free to benefit.. 19 ANDROID OS VESRIONS The following table shows the versions of Android: Platform API level Year Android 3.0 (Honeycomb) 11 2011 Android 2.3 (Gingerbread) 9/10 Dec. 6, 2010 Android 2.2 (Froyo) 8 Jan. 10, 2010 Android 2.1 (Eclair) 7 Oct. 26, 2009 Android 1.6 (Donut) 4 Sept. 15, 2009 Android 1.5 (Cupcake) 3 April 30, 2009. 20 ANDROID OS VESRIONS The following table shows the versions of Android: Platform API level Year Android 7.0 (Nougat) 24-25 Aug. 22,2016 Android 6.0 23 Oct. 5, 2015 (Marshmallow) Android 5.0 (Lollipop) 21-22 Nov. 12, 2014 Android 4.4 (KitKat) 19-20 Oct. 31, 2013 Android 4.3 (Jelly Bean) 16-18 July, 9, 2012 Android 4.0 (Ice cream 14-15 October 18, 2011 Sandwich). 21 ANDROID OS VESRIONS The following table shows the versions of Android: Platform API level Year Android 9.0 (Pie) 28 Aug.6,2018 Android 8.0 (Oreo) 26-27 Aug.21,2017. 22 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”). 23 WHAT IS ANDROID? 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.. 24 WHY ANDRIOID? 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. 25 FEATURES 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). 26 FEATURES cont. 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. 27 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.. 28 WHAT ANDROID ISN’T cont. ❑ 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.. 29 WHAT ANDROID ISN’T cont. ❑ 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.. 30 NATIVE ANDROID 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. 31 NATIVE ANDROID APPLICATIONS ❑ 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.. 32 NATIVE ANDROID APPLICATIONS cont All the native applications are written in Java using the Android SDK and are run on Dalvik. The data stored and used by the native applications — like contact details — are also available to third party applications. Similarly, your applications can handle events such as an incoming call or a new SMS message.. 33 WHAT DOES IT HAVE THAT OTHERS DON’T ❑ 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. 34 WHAT DOES IT HAVE THAT OTHERS DON’T cont. ❑ 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 service that changes your ring tone or volume depending on your current location, the time of day, and the identity of the caller.. 35 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 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.. 36 WHAT MAKES AN ANDROID APPLICATION? Cont. ❑ 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 configure 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.. 37 WHAT MAKES AN ANDROID APPLICATION? Cont. ❑ Broadcast Receivers Intent broadcast consumers. By creating and registering a Broadcast Receiver, your application can listen for broadcast Intents that match specifi c filter criteria. Broadcast Receivers will automatically start your application to respond to an incoming Intent, making them ideal for event-driven applications. ❑ Notifications A user notification framework. Notifications 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.. 38 FUNDAMENTAK ANDROID UI DESIGN 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.. 39 FUNDAMENTAK ANDROID UI DESIGN cont. ❑ 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.. 40 FUNDAMENTAK ANDROID UI DESIGN cont. ❑ 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.. 41 ANDROID WIDGET TOOLBOX 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. 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.. 42 ANDROID WIDGET TOOLBOX cont. ❑ 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.. 43 ANDROID WIDGET TOOLBOX cont. ❑ 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. 44 ANDROID WIDGET TOOLBOX cont. ❑ 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.. 45 ANDROID WIDGET TOOLBOX cont. 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.. 46 ANDROID WIDGET TOOLBOX cont. TextView, EditText, and Button. 47 The Size of the Mobile Market http://gizmodo.com/5489036 /cellphone-overshare [see appendix] 15 Android Components (Stack) The Android stack includes a large array of features for mobile applications. It would be easy to confuse Android with a general purpose computing environment. All of the major components of a computing platform are included. 16 Android Components Application framework enabling reuse and replacement of components Dalvik virtual machine optimized for mobile devices 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 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 WiFi (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 plugin for the Eclipse IDE 17 Android Components 18 Why use Linux for a phone? Linux kernel is a proven core platform. Reliability is more important than performance when it comes to a mobile phone, because voice communication is the primary use of a phone. Linux can help meet this requirement. Linux provides a hardware abstraction layer, letting the upper levels remain unchanged despite changes in the underlying hardware. As new accessories appear on the market, drivers can be written at the Linux level to provide support, just as on other Linux platforms. 24 Dalvik Virtual Machine User applications, as well as core Android applications, are written in Java programming language and are compiled into byte codes. Android byte codes are interpreted at runtime by a processor known as the Dalvik virtual machine. 25 Why another JavaVirtual Machine? Android bytecode files are logically equivalent to Java bytecodes, but they permit Android to – run its applications in its own virtual environment that is free from Sun’s licensing restrictions and – an open platform upon which Google, and potentially the open source community, can improve as necessary. 26 Inside Android: Intents An important and recurring theme of Android development is the Intent. An Intent in Android describes what you want to do. This may look like – “I want to look up a contact record,” or – “Please launch this website,” or – “Show the Order Confirmation Screen.” Intents are important because they facilitate navigation and represent the most important aspect of Android coding. 28 Android Applications Each Android application runs in its own Linux process. An application consists of a combination of software components including: – Activities – Services – Broadcast Receivers – Content Providers 45 Android Applications Structure of a typical Android Application 46 Android Services A Service is an application component that runs in the background, not interacting with the user, for an indefinite period of time. Each service class must have a corresponding declaration in its package's AndroidManifest.xml. Services can be started/stopped with – Context.startService() and – Context.bindService(). – stopService(…) and unbindService(…) 47 Android Services Services, like other application objects, run in the main thread of their hosting process. This means that, if your service is going to do any CPU intensive (such as MP3 playback) or blocking (such as networking, RSS exchange) operations, it should spawn its own thread in which to do that work 48 Android Services Service1 Class package matos.service; import android.app.Service; import android.content.Intent; import android.os.IBinder; import android.util.Log; public class Service1 extends Service implements Runnable { private int counter = 0; @Override public void onCreate() { super.onCreate(); Thread aThread = new Thread(this); aThread.start(); } public void run() { while (true) { try { Log.i("service1", "service1 firing : # " + counter++); Thread.sleep(10000); //this is where the heavy-duty computing occurs } catch (Exception ee) { Log.e("service1", ee.getMessage()); } } } @Override public IBinder onBind(Intent intent) { return null; } } 49 Android Services // Service1Driver package matos.service; import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class Service1Driver extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // invoking the service Intent service1Intent = new Intent( this, Service1.class ); startService( service1Intent ); } }// Service1Driver 50 Android Services Service1Demo Manifest 51 Android Services Debugging - Log Cat 07-01 02:49:46.097: INFO/ActivityManager(583): Displayed activity matos.service /.Service1 Driver 07-01 02:49:51.277: DEBUG/dalvikvm(724): GC freed 1575 objects / 81280 bytes in 138ms 07-01 02:49:55.831: INFO/service1(767): service1 firing : # 1 07-01 02:50:05.839: INFO/service1(767): service1 firing : # 2 07-01 02:50:15.847: INFO/service1(767): service1 firing : # 3 07-01 02:50:25.857: INFO/service1(767): service1 firing : # 4 52 Android Broadcast Receiver What is a BROADCASTRECEIVER? If an application wants to receive and respond to a global event, such as the phone ringing or an incoming text message, it must register as a BroadcastReceiver. An application registers to receive Intents by announcing in the AndroidManfest.xml file its IntentFilters. If the receiver is registered in the AndroidManifest.xml file, it does not have to be running in order to be triggered. When the global event occurs, the application is started automatically upon notification of the triggering event. All of this housekeeping is managed by the Android OS itself. An application may register at runtime via the Context class’s registerReceiver method. 53 Android Manifest xml File Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory. The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code. 72 Android Manifest xml File These are the only legal elements; you cannot add your own elements or attributes. 73 Android Manifest xml File Among other things, the manifest does the following: – It names the Java package for the application. The package name serves as a unique identifier for the application. – It describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. – It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched. – It determines which processes will host application components. – It declares which permissions the application must have in order to access protected parts of the API and interact with other applications. – It also declares the permissions that others are required to have in order to interact with the application's components. – It lists the Instrumentation classes that provide profiling and other information as the application is running. These declarations are present in the manifest only while the application is being developed and tested; they're removed before the application is published. – It declares the minimum level of the Android API that the application requires. – It lists the libraries that the application must be linked against. 74 Example. Currency converter 81 Additional Resources Google Developer Conference San Francisco – 2009 Web page: http://code.google.com/events/io/ 85 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 Mobile market 480 m compared to other Papers technologies 1.4bn Internet users worldwide 4 bn Mobile Phone worldwide (half the population of the planet) 1.5bn 5.33% 6.69% Business Directory Televisions Movie information worlwide 7.13% Traded Stocks and Financial 11.94% t News 48.7% News and Sport Information 20.21% 2009 Social Content being Networking accessed from mobiles 86 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 - Top visited Mobile websites 10.99% MySpace MySpace Mobile 19.39% Mocospace 2009 Mobile Revenue 5.03% 2.38% orld Thumplay Offers 4.7% $130 bn 2.38% Cricket Fun For Mobile Messaging 2.53% 2.98% Yahoo Mobile Phone Zoo $600 bn $70 bn Voice Non-messaging 87 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 Mobile Search Market 1.94% Yahoo 97.57% 2.43% Google 0.63% Other 0.25% Ask 0.11% MSM 88 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare Top 5 Smartphone mobile web traffic in the US 23% of market made up of traffic from other smartphones 49.5% iPhone HTC Dream Palm Centro 16% RIM Blackberry 89 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 Mobile Operating System Market Share Worldwide 19% 13% iPhone RIM 9% Windows 6% Other 2% Android 51% Symbian 90 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 3% Fujitsu Smartphone Sales Worldwide 6% HTC 14% Other 45% Nokia 13% Apple 19% RIM 2009 How 25% is Accessed from Mobile 46% exclusively use both PC and Mobile 29% from PC exclusively 91 Appendix. The Sixe of the Mobile Market – 2009 Extracted from: http://gizmodo.com/5489036/cellphone-overshare 2009 How SMS compares as a text communication application 3.05 bn SMS users worldide 2.6 SMS per day per person world average 600 m the most used used communication IM users tool of the net worldwide 1.3 bn Email users worldwide 92

Use Quizgecko on...
Browser
Browser