Android application development ppt

android application development ppt presentation free download and android development tutorial for beginners ppt
CharlieNixon Profile Pic
CharlieNixon,United Kingdom,Researcher
Published Date:13-07-2017
Your Website URL(Optional)
Comment
Università Degli Studi di Parma Distributed Systems Group Android Development Lecture 2 Android Platform Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Lecture Summary The Android Platform - Dalvik Virtual Machine - Application Sandbox - Security and Permissions - Traditional Programming compared to Android - Activities - Services - Content Providers - Intents - Broadcast Receivers - Android Application Structure - Android Application Manifest - Model View Controller - User Interface - 2 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group The Android Platform Android is a software stack for mobile devices that includes an operating system, - middleware and key applications. The Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language. It is a Linux-based operating system for mobile devices such as smartphones and - tablet computers. It is developed by the Open Handset Alliance led by Google. The Linux 2.6 kernel handles core system services and acts as hardware abstraction - layer (HAL) between the physical hardware and the Android Software Stack. Kernel handles: - Application permissions and security ‣ Low-level energy management ‣ Process management and Threading ‣ Networking ‣ Display, keypad input, camera, Flash memory, audio and binder (IPC) driver access ‣ Source: Wikipedia, AWA, http://developer.android.com/guide/developing/tools/aidl.html 3 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Android Application A Android Application A Android Application A Written Using Android Written Using Android Written Using Android Java Framework Java Framework Java Framework DALVIK Virtual Machine DALVIK Virtual Machine DALVIK Virtual Machine Linux User Linux User Linux User A B C Linux 2.6 Operating System (Hardware Abstraction Layer) Security Process I/O Other Devices Memory Management Network Power WiFi, Bluetooth, Camera, Audio, Telephony, Flash, Management Stack Display, Keyboard, Management Device Sensors Binder IPC Touchscreen Physical Hardware Source: AWA-Chapter1 4 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Dalvik Virtual Machine It is the Android Virtual Machine, based on the Java VM but optimized for mobile devices. - Has a small memory footprint, and multiple instances of Dalvik VM can run concurrently on the - device. Programs are mainly written in a dialect of Java and compiled to bytecode. They are converted - from Java Virtual Machine-compatible .class files to Dalvik-compatible .dex (Dalvik Executable) files before installation on a device. The compact Dalvik Executable format is designed to be suitable for systems that are constrained in terms of memory and processor speed. Each Android application runs in a separate process, with its own instance of the Dalvik virtual - machine. Android application life cycle (next lecture) enables the OS to enhance the performance of the - garbage collection and how it manages memory recovery across multiple heaps. Source: PA-Chapter 3 - AWA Chapter 1 5 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Application Sandbox Android security is strictly related to restriction and security - levels of the Linux operating system and in particular on process and user-level boundaries. App A Android creates a new user for each application vendor. Each - application it is executed with different user privileges (expect File DB SMS Logs for those signed by the same vendor). Sensors Network .... Files owned by one application are, by default, inaccessible - by other applications. The SDK provides Content Provider and Intent to allows - Android applications to communicate and exchange data. OS App B This solution has been adopted to provide an high security in - a world of numerous third part small applications from File DB SMS Logs different vendors. Sensors Network .... The sandbox approach is a common solution for mobile - operating systems such as iOS. Source: PA-Chapter 3 - http://www.ibm.com/developerworks/xml/library/x-androidsecurity/ - http://source.android.com/tech/ 6 Marco Picone - 2012 security/index.htmlthe-application-sandboxUniversità Degli Studi di Parma Distributed Systems Group Application Sandbox - Same User ID App Sandbox: Linux user ID 54321 App Sandbox: Linux user ID 12345 Application Application Linux User ID: 54321 Linux User ID: 12345 Resources Resources Linux user ID: 54321 Linux user ID: 12345 File DB SMS Logs File DB SMS Logs Network Sensors .... Network Sensors .... Source: PA-Chapter 3 - http://www.ibm.com/developerworks/xml/library/x-androidsecurity/ - http://source.android.com/tech/ 7 Marco Picone - 2012 security/index.htmlthe-application-sandboxUniversità Degli Studi di Parma Distributed Systems Group Application Sandbox - Same User ID App Sandbox: Linux user ID 12345 Application Application Linux User ID: 12345 Linux User ID: 12345 Resources Linux user ID: 12345 File DB SMS Logs File DB SMS Logs Network Sensors .... Network Sensors .... Source: PA-Chapter 3 - http://www.ibm.com/developerworks/xml/library/x-androidsecurity/ - http://source.android.com/tech/ 8 Marco Picone - 2012 security/index.htmlthe-application-sandboxUniversità Degli Studi di Parma Distributed Systems Group Security and Permissions Android platform adopts several security and integrity measures to ensure that the user’s data is secure and - that the device is note subject to malware. Application as Operating System Users (Dalvik instance and sandboxes) - Application Permissions - Each application registers for specific privileges to access shared resources. Some of these privileges are ‣ related for example to phone functionalities, make calls, access network file and system, control the camera or the other hardware sensors. Additional permission are dedicated to access private and personal information, such as preferences, ‣ user’s contacts or location. Limited Ad-Hoc Permissions - Applications that use a Content Provider to openly share specific information to other applications can ‣ define some on-the-fly permission to grant o revoke access to a resource. Application Signing - All application are signed with a certificate to allow the users to know that the application is authentic. ‣ Source: http://developer.android.com/guide/topics/security/security.html 9 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Traditional Programming compared to Android OS Process Traditional OS applications: - use a single entry point (traditionally called main). ‣ Application The OS loads the program into a process and main()... then start executing it (Fig. A). OS Process Java VM Java based applications: - Application main()... are managed in a different way. A Java VM is ‣ instantiated in a dedicated process to load all Thread Thread classes used by the application and execute it. Source: http://developer.android.com/guide/topics/fundamentals.html 10 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Traditional Programming compared to Android Android introduces a more complex system supporting - multiple application entry points. Each component is a OS Process different point through which the system can enter your application. Not all components are actual entry points Dalvik VM for the user and some depend on each other, but each one exists as its own entity and plays a specific role each Application with multiple entry points one is a unique building block that helps define your application's overall behavior. There are four different types of application components. Activity 1 Activity 2 Activity 3 - Each type serves a distinct purpose and has a distinct Thread Thread Thread lifecycle that defines how the component is created and destroyed. Main application entry points are: Service 1 Service 2 Activities ‣ (No UI) (No UI) Thread Thread Services ‣ Content Providers ‣ Broadcast Receivers ‣ Source: http://developer.android.com/guide/topics/fundamentals.html 11 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Activities Is both a unit of user interaction (typically associated - Activity 1 back button to a View) and a unit of execution. To create an activity, you must create a subclass of - Activity 2 Activity (or a subclass of it such as MapActivity). 1 Multiple Activities (related also to different - Activity 3 applications) are organized in a stack structure where new elements can be pushed or removed after View 2 specific user actions (UI interaction or back button). Although activities work together to form a cohesive - View 3 user experience in application, each one is independent of the others. As such, a different application can start any one of these activities. For example, a camera application can start the activity in the email application that composes new mail, in startActivity() order for the user to share a picture. Source: http://developer.android.com/guide/topics/fundamentals.html Marco Picone - 2012 12Università Degli Studi di Parma Distributed Systems Group Activity Life Cycle Activity 4 Top Activity. View 4 User can interact with it Activity 3 Second Activity in the stack. If the user clicks back or the Top Activity is destroyed View 2 the user can see and interact with it again Activity 2 Activity in the middle of the stack. User cannot interact with it until every activity above it View 2 is destroyed. Activity 1 Activity at the bottom of the stack. If Activities above it use too many resources it will be View 1 destroyed. Source: AWA Chapter 4 13 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Killable Method Description Next after? Activity Life Cycle Called when the activity is first created. This is where onCreate() you should do all of your normal static set up — create No onStart() views, bind data to lists, and so on. Called after the activity has been stopped, just prior onRestart() No onStart() to it being started again. onResume() Called just before the activity becomes visible to the onStart() or user. onStop() Called just before the activity starts interacting with onResume() No onPause() the user. At this point the activity is at the top of the activity stack, with user input going to it. Called when the system is about to start resuming another activity. This method is typically used to onResume() commit unsaved changes to persistent data, stop or onPause() animations and other things that may be consuming CPU, Yes onStop() and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns. Called when the activity is no longer visible to the onRestart() user. This may happen because it is being destroyed, or onStop() Yes or because another activity (either an existing one or a onDestroy() new one) has been resumed and is covering it. Called before the activity is destroyed. This is the final call that the activity will receive. It could be onDestroy() called either because the activity is finishing, or Yes nothing because the system is temporarily destroying this instance of the activity to save space. Source: http://developer.android.com/guide/topics/fundamentals/activities.html 14 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Saving Activity State When the system destroys an activity in order to - recover memory, the Activity object is destroyed, so the system cannot simply resume it with its state intact. If the user navigates back to the destroyed Activity - the system needs to recreate the object. The user is unaware that the system destroyed the activity and recreated it and, thus, probably expects the activity to be exactly as it was. In this situation Android OS provides a method called - onSaveInstanceState() ensure that important information about the activity state is preserved. Source: http://developer.android.com/guide/topics/fundamentals/activities.html 15 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Service The Android Service class is for background operations - that are active but not visible to the user. It is used too perform a longer-running operation while - not interacting with the user or to supply functionality for other applications to use (chat service, HTTP fetcher, GPS Location tracking). Additionally, a component can bind to a service to - interact with it and even perform interprocess communication (IPC). For example, a service might handle network transactions, play music, perform file I/ O, or interact with a content provider, all from the background. Has a life cycle similar to the one presented for the - Activity and has two main method to control its life such as start, stop and restart. Source: http://developer.android.com/guide/topics/fundamentals/services.html 16 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Content Providers Content Providers (CPs) manage access to a structured set of - Android Application 2 Android Application 3 data (Files or Databases). Activity Activity They encapsulate the data, and provide mechanisms for - defining data security. Content providers are the standard interface that connects data in one process with code running in another process. Other applications can access information of a content provider - through a specific URI ( content:// ). Android Application 1 Typical provided operations are: - Activity 1 Create Insert ‣ Content Provider Read Query ‣ Activity 2 Update ‣ Delete ‣ Android OS provides some built-in CPs for Browser, Calendar, - File SQLite Remote Contacts, Call Log, Media and Setting allowing the access to those data from other active applications. Source: PA-Chapter3 - http://developer.android.com/guide/topics/providers/content-providers.html 17 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Intents Intents are asynchronous messages allowing OS - components to request functionality from other system elements. For example an Activity can send an Intent to Message List Activity the Android system to starts another Activity. View WebView Message Intents can be used to signal to the Android system that a Open Website - Activity Intent Intent certain event has occurred. Other components in Android View can register to this event and will get notified. Message Activity Intents are send to the Android system. Depending on - how the Intent was constructed the Android system will run an receiver determination and determine what to do. View Video Intent An Intent can also contain data. This data can be used by - the receiving component. For example your application Video View can calls via an Intent a browser component. As data is it Activity may send the URL to the browser component. Android supports explicit and implicit Intents. - Source: http://developer.android.com/guide/topics/intents/intents-filters.html / http://www.vogella.de/articles/AndroidIntent/ 18 Marco Picone - 2012 article.htmlUniversità Degli Studi di Parma Distributed Systems Group Broadcast Receiver Represent a variant of communication between different process based on Intent objects. - An application or directly the system - Many broadcasts originate from the system—for example, a broadcast announcing that the - screen has turned off, the battery is low, or a picture was captured. Applications can also initiate broadcasts for example, to let other applications know that some - data has been downloaded to the device and is available for them to use. They do not display a user interface, but may create a status bar notification to alert the user - when a broadcast event occurs. To simplify a broadcast receiver is just a "gateway" to other components and is intended to do a - very minimal amount of work. For instance, it might initiate a service to perform some work based on the event. Source: PA-Chapter3 / http://developer.android.com/guide/topics/fundamentals.html 19 Marco Picone - 2012Università Degli Studi di Parma Distributed Systems Group Android Application Structure Android Manifest.xml - res/ - layout/ application layout files ‣ drawable/ images, patches, drawable, xml ‣ raw/ data files that can be loaded as streams ‣ values/ xml files with strings, number values used in the code for ‣ example to localize the application in difference languages src/ - java/package/directories ‣ gen/ directory generated by Eclipse and Android SDK - 20 Marco Picone - 2012