撰寫:2025/1/12
發佈: 2025/1/18
Android-01 Ecllipse - Developer Guide 1 Basic
2012時Android 開發技術資料有以下的內容:
Android Basics
- An initial orientation to Android — Application Fundamentals.
Framework Topics
- Discussions of particular parts of the Android framework and API.
Android Market Topics
- Documentation for topics that concern publishing and monetizing applications on Android Market, such as how to enforce licensing policies and implement in-app billing.
Developing
- Directions for using Android's development and debugging tools, and for testing the results.
Publishing
- Instructions on how to prepare your application for deployment and how to publish it when it's ready.
Best Practices
- Recommendations on preferred techniques for writing applications that perform efficiently and work well for the user.
Web Applications
- Documentation about how to create web applications that work on Android devices and embed web-based content.
Appendix
- Reference information and specifications, as well as FAQs, a glossary of terms.
個人認為瞭解順序為
1. Android Basics, 2. Developing, 3. Framework, 4. Best Practices, 5. Android Market Topics, 6. Publishing, 7. Web Applications.
但是重點主要還是在Framework,有關的內容有以下部分:
- Activities
- Services
- Content Providers
- Intents and Intent Filters
- Processes and Threads
- User Interface
- Application Resources
- Data Storage
- Security and Permissions
- The AndroidManifest.xml File
- Graphics
- RenderScript
- Media updated
- Copy and Paste
- Location and Maps
- App Widgets
- Bluetooth
- Near Field Communication
- USB
- Session Initiation Protocol
- Search
- Device Administration
- Testing
但在此不會一一說明,重點主要在兩部分,分別如下:
- Android Architecture
- Application Fundamentals
Android Architecture
首先介紹Android Architecture如下圖:
第二層Application Framework有以下重點:
- Activity Manager: that manages the lifecycle of applications and provides a common navigation backstack
- Views: that can be used to build UI of 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
- Resource Manager: providing access to non-code resources such as localized strings, graphics, and layout files
- Notification Manager: that enables all applications to display custom alerts in the status bar
第三層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's OpenCORE; 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
第四層Android Runtime有以下重點:
- Core libraries: that provides most of the functionality in the core libraries of the Java programming language.
- Dalvik virtual machine: every Android application runs in its own process, with its own instance of the Dalvik VM. Dalvik has been written so that a device can run multiple VMs efficiently.
- The Dalvik VM executes files in the Dalvik Executable (.dex) format which is optimized for minimal memory footprint. The VM is register-based, and runs classes compiled by a Java language compiler that have been transformed into the .dex format by the included "dx" tool.
- The Dalvik VM relies on the Linux kernel for underlying functionality such as threading and low-level memory management.
Application Fundamentals
Application Fundamentals包括以下重點:
- Installation and Execution Process
- Share Data and System Service
- Application Components
分別說明如下:
Installation and Execution Process有關安裝及執行的程序有以下需要注意的地方:
- Android SDK tools compile the code “along with any data and resource files” into an Android package, an archive file with an .apk suffix, use to install the application.
- Once installed on a device, each Android application lives in its own security sandbox
- The Android operating system is a multi-user Linux system in which each application is a different user. Each process has its own VM.
- By default, the system assigns each application a unique Linux user ID (the ID is unknown to the application). The system sets permissions for all the files in application, only the application with user ID can access them.
- In this way, the Android system implements the principle of least privilege. Each application has access only to the components that it requires to do and no more and it cannot access parts of the system for which it is not given permission.
有關Share Data and System Service分享系統服務與資料有以下需要注意的地方:
- There are ways for an application to share data with other applications and for an application to access system services
- Same Linux user ID: It's possible to arrange for two applications to share the same Linux user ID, in which case they are able to access each other's files. The same user ID can also arrange to run in the same Linux process and share the same VM.
- Request permission: An application can request permission to access device data such as the user's contacts, SD card... All application permissions must be granted by user at install time.
有關Application Components應用程式的元件有以下需要注意的地方:
- Application components are the essential building blocks of an Android application. Each component is a different point through which the system can enter your application. Not all components are actual entry points, but each one exists as its own entity and plays a specific role—that helps define your application's overall behavior.
- A unique aspect of the Android system design is that any application can start another application’s component. E.g. capture a photo with the camera, can simply start the activity in the camera application.
- When the system starts a app component, it starts the process that application.
- Each application in a separate process with file permissions that restrict access to other applications, your application cannot directly activate a component from another application. The Android system, however, can. So you must deliver a message to the system that specifies your intent to start a particular component.
有關Application Components應用程式的元件有四種型態:
- Activities: An activity represents a single screen with a user interface. E.g. 3 activities work together to form a email app, each one is independent.
- Services: A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. E,g. music playing.
- Content providers: A content provider manages a shared set of application data. E.g. data in the file system, an SQLite DB, on the web.
- Broadcast receivers: A broadcast receiver is a component that responds to system-wide broadcast announcements.
至於如何激發Application Components有三大類方法:
- Intent: Activities, services, and broadcast receivers—are activated by an asynchronous message called an intent.
- For activities and services, intent defines the action to perform (e.g. "view" or "send") and may specify the URI of the data.
- For broadcast receivers, the intent simply defines the announcement being broadcast .
- Content Resolver: for content provider, it is activated when targeted by a request from a Content Resolver. The content resolver handles all direct transactions with the content provider so that the component that's performing transactions with the provider doesn't need to and instead calls methods
- Separate methods for activiting each type of component:
- Activities: You can start an activity by passing an Intent to startActivity() or startActivityForResult().
- Services: You can start a service by passing an Intent to startService(). Or you can bind to the service by passing an Intent to bindService().
- Broadcast receivers: You can initiate a broadcast by passing an Intent to methods like sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().
- Content providers: You can perform a query to a content provider by calling query() on a ContentResolver.
最後有關The Manifest File有以下重點資訊:
- Before the Android system can start an application component, the system must know that the component exists by reading the application's AndroidManifest.xml
- Manifest file declare the application's components
- Identify any user permissions the application requires, such as Internet access or read-access to the user's contacts.
- Declare the minimum API Level required by the application, based on which APIs the application uses. E.g. Android 2.1 (API Level 7),
- Declare hardware and software features used or required by the application, such as a camera, bluetooth services, or a multitouch screen.
- API libraries the application needs to be linked against (other than the Android framework APIs), such as the Google Maps library.
- User can start activities by explicitly naming the target component (using the component class name) in the intent.
- The real power of intents lies in the concept of intent actions. With intent actions, you simply describe the type of action you want to perform.
- system identifies the components that can respond to an intent is by comparing the intent received to the intent filters. you can optionally include intent filters.
主要在宣示應用程式所需,所以有幾個重點:
- For example, if your application requires a camera and uses APIs introduced in Android 2.1 (API Level 7), you should declare these as requirements in your manifest file.
- Required important device characteristics :
- Screen size and density: screen sizes are: small, normal, large, and extra large. screen densities are: low density, medium density, high density, and extra high density. Define with <supports-screens>
- Input configurations: If application requires a particular of input hardware, then declare <uses-configuration> element in manifest.
- Device features: many hardware and software features that may or not exist on a given Android device camera, touch screen…etc. you should declare any features used by your application with the <uses-feature> element.
- Platform Version: Each platform version specifies an API Level.declare the minimum API Level in the <uses-sdk> element.
有關這部分的訓練資料,可在此連結下載:
後記
本文為個人學習的經驗,後續有所改進將再發文分享;本人因工作因素發文後並不會經常檢視讀者問題,對於沒法及時回覆問題敬請見諒!
若覺本文對讀者有所幫助,可回覆感想及你的分享!謝謝!
留言列表