5. The stack II Overview Presentation 5 Android is a layered environment built upon a foundation of Linux kernel. Android applications are written in Java programming language and they run in Dalvik Virtual Machine, an open source technology. Each Android application runs within an instance of the Dalvik VM, which in turn resides within a Linux-kernel managed process
6. The stack III Overview Presentation 6 Android platform layers:
7. The stack IV Overview Presentation 7 In more detail:
8. Application framework Overview Presentation 8 Developers have full access to the same framework APIs used by the core applications. The application architecture is designed to simplify the reuse of components; any application can publish its capabilities and any other application may then make use of those capabilities (subject to security constraints enforced by the framework). This same mechanism allows components to be replaced by the user. Underlying all applications is a set of services and systems, including: A rich and extensible set of Views that can be used to build an application, including lists, grids, text boxes, buttons, and even an embeddable web browser Content Providers that enable applications to access data from other applications (such as Contacts), or to share their own data A Resource Manager, providing access to non-code resources such as localized strings, graphics, and layout files A Notification Manager that enables all applications to display custom alerts in the status bar An Activity Manager that manages the lifecycle of applications and provides a common navigation backstack
9. Libraries System C library - a BSD-derived implementation of the standard C system library (libc), tuned for embedded Linux-based devices Media Libraries - based on PacketVideo'sOpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG Surface Manager - manages access to the display subsystem and seamlessly composites 2D and 3D graphic layers from multiple applications LibWebCore - a modern web browser engine which powers both the Android browser and an embeddable web view SGL - the underlying 2D graphics engine 3D libraries - an implementation based on OpenGL ES 1.0 APIs; the libraries use either hardware 3D acceleration (where available) or the included, highly optimized 3D software rasterizer FreeType - bitmap and vector font rendering SQLite - a powerful and lightweight relational database engine available to all applications Overview Presentation 9 Android includes a set of C/C++ libraries used by various components of the Android system. These capabilities are exposed to developers through the Android application framework. Some of the core libraries are listed below:
10. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 10
11. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 11
13. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 13
14. The AndroidManifest.xml File Overview Presentation 14 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. It names the Java package for the application. The package name serves as a unique identifier for the application.
15. The AndroidManifest.xml File 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 declares which permissions the application must have in order to access protected parts of the API and interact with other applications. Overview Presentation 15
16. The AndroidManifest.xml File It also declares the permissions that others are required to have in order to interact with the application's components. It declares the minimum level of the Android API that the application requires. It lists the libraries that the application must be linked against Overview Presentation 16 List is not complete !!!!!
17.
18. A set of XML elements and attributes for declaring a manifest file
19. A set of XML elements and attributes for declaring and accessing resources
21. A set of permissions that applications can request, as well as permission enforcements included in the systemEach successive version of the Android platform can include updates to the Android application framework API that it delivers.
24. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 20
25. Activity An activity is a core component of the Android platform. Each activity represents a task the application can do, often tied to a corresponding screen in the application user interface. Activity is to an application what a web page is to a website. (Sort of) Overview Presentation 21
26. Activities lifecycle Overview Presentation 22 Activities have a well defined lifecycle. The Android OS manages your activity by changing its state. Demo
27. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 23
28. Intents Overview Presentation 24 Intents are to Android apps what hyperlinks are to websites. An application can call directly a service or activity (explicit intent) or asked the Android system for registered services and applications for an intent (implicit intents). Intents are asynchronous messages.
29. Intents / Starting activities Samples Overview Presentation 25 Standard Explicit intents : Intent intent = new Intent(getApplicationContext(), HelpActivity.class); startActivity(intent); Extra parameters: Intent intent = new Intent(getApplicationContext(), HelpActivity.class); intent.putExtra(“eu.laracker.supersocial.LEVEL”, 8); startActivity(intent); Intent callingIntent = getIntent(); inthelpLevel = callingIntent.getIntExtra(“eu.laracker.supersocial.LEVEL”, 1); Calling with result: startActivityForResult(new Intent(getApplicationContext(), HelpActivity.class);) onActivityResult(intrequestCode, intresultCode, Intent data);
30. Using Intents to Launch Other Applications Overview Presentation 26 Initially, an application may only be launching activity classes defined within its own package. However, with the appropriate permissions, applications may also launch external activity classes in other applications. Launching the built-in web browser and supplying a URL address Launching the web browser and supplying a search string Launching the built-in Dialer application and supplying a phone number Launching the built-in Maps application and supplying a location Launching Google Street View and supplying a location Launching the built-in Camera application in still or video mode Launching a ringtone picker Recording a sound
31. Using Intents to Launch Other Applications samples Overview Presentation 27 Launching the built-in web browser and supplying a URL address Implicit Intents: Uri address = Uri.parse(“http://www.planon-fm.com”); Intent surf = new Intent(Intent.ACTION_VIEW, address); startActivity(surf); AndroidManifest.xml <uses-permissionandroid:name="android.permission.INTERNET" /> Which browser is openend is unknown, Android OS looks at the registered intend filters.
39. What are the main components of a Android application Part I, today Short introduction in Eclipse AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 31
41. Application resources Overview Presentation 33 You should always externalize resources such as images and strings from your application code, so that you can maintain them independently. Externalizing your resources also allows you to provide alternative resources that support specific device configurations such as different languages or screen sizes Resource types are defined with special XML tags and organized into specially named project directories. Some examples of /res subdirectories are /drawable, /layout, and /values.
42.
43. Alternative resources are those that you've designed for use with a specific configuration. To specify that a group of resources are for a specific configuration, append an appropriate configuration qualifier to the directory name.Application resources Overview Presentation 34 Demo
44. Sample resource file String Overview Presentation 35 You can use string resources anywhere your application needs to display text. You tag string resources with the <string> tag and store them in the resource file /res/values/strings.xml. <?xml version=”1.0” encoding=”utf-8”?> <resources> <string name=”app_name”>Name this App</string> <string name=”hello”>Hello</string> </resources> Referenced in XML: @string/hello Referenced in Java: getResources().getString(R.string.hello);
45. Sample resource file Drawable Overview Presentation 36 Drawable resources, such as image files, must be saved under the /res/drawable project directory. Referenced in XML: @drawable/icon Referenced in Java: logoView.setImageResource(R.drawable.icon); AndroidManifest.xml snippet: <application android:icon="@drawable/icon" android:label="@string/app_name">
46. Layouts (A world on his own) Overview Presentation 37 Layout files often define an entire screen and are associated with a specific activity, but they need not be. Layout resources can also define part of a screen and can be included within another layout. Layouts can also be created, modified, and used at runtime. However, in most cases, using the XML layout files greatly improves code clarity and reuse. Idea for next time ?????
47. What are the main components of a Android application Part I, today AndroidManifest.xml Activity Intents Application resources Layouts Localization Part II, next time Application preferences App Widgets Services broadcast receivers content providers Overview Presentation 38
49. Resources on the web http://developer.android.com/index.html http://www.vogella.de Tuturial http://developer.android.com/resources/tutorials/notepad/index.html Overview Presentation 40