应用的基本原理:
Quickview:
Android applications are composed of one or more application components (activities, services, content providers, and broadcast receivers)
Each component performs a different role in the overall application behavior, and each one can be activated individually (even by other applications)
The manifest file must declare all components in the application and should also declare all application requirements, such as the minimum version of Android required and any hardware configurations required
Non-code application resources (images, strings, layout files, etc.) should include alternatives for different device configurations (such as different strings for different languages and different layouts for different screen sizes)
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.
By default, the system assigns each application a unique Linux user ID
Each process has its own virtual machine (VM)
By default, every application runs in its own Linux process
However, there are ways for an application to share data with other applications and for an application to access system services:
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.
Activities:An activity represents a single screen with a user interface. An activity is implemented as a subclass of Activity
Services:A service is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface.A service is implemented as a subclass of Service
Content providers:A content provider manages a shared set of application data. You can store the data in the file system, an SQLite database, on the web, or any other persistent storage location your application can access. Through the content provider, other applications can query or even modify the data (if the content provider allows it).A content provider is implemented as a subclass of ContentProvider and must implement a standard set of APIs that enable other applications to perform transactions.
Broadcast receivers:A broadcast receiver is a component that responds to system-wide broadcast announcements. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. For more information, see the BroadcastReceiver class.
A unique aspect of the Android system design is that any application can start another application’s component.
When the system starts a component, it starts the process for that application (if it's not already running) and instantiates the classes needed for the component. Android applications don't have a single entry point (there's no main() function)
Because the system runs 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, to activate a component in another application, you must deliver a message to the system that specifies your intent to start a particular component. The system then activates the component for you.
Activating Components:Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent.The other component type, content provider, is not activated by intents.The other component type, content provider, is not activated by intents. Rather, it is activated when targeted by a request from a ContentResolver.
There are separate methods for activiting each type of component:
You can start an activity (or give it something new to do) by passing an Intent to startActivity() or startActivityForResult() (when you want the activity to return a result).
You can start a service (or give new instructions to an ongoing service) by passing an Intent to startService(). Or you can bind to the service by passing an Intent to bindService().
You can initiate a broadcast by passing an Intent to methods like sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().
You can perform a query to a content provider by calling query() on a ContentResolver.
The Manifest File:
Activities, services, and content providers that you include in your source but do not declare in the manifest are not visible to the system and, consequently, can never run. However, broadcast receivers can be either declared in the manifest or created dynamically in code (as BroadcastReceiver objects) and registered with the system by calling registerReceiver().
When you declare a component in your application's manifest, you can optionally include intent filters that declare the capabilities of the component so it can respond to intents from other applications. You can declare an intent filter for your component by adding an <intent-filter> element as a child of the component's declaration element.
分享到:
相关推荐
在Android系统原理与开发要点详解中,我们将会深入探讨Android操作系统的核心机制以及开发者在构建应用程序时需要关注的关键点。Android作为一个开源的移动操作系统,它的架构包括了多个层次,从底层的Linux内核到...
此外,还介绍了垃圾回收的基本原理和性能优化策略。 第六章《Android进程间通信》:深入解析Android中的IPC(Inter-Process Communication)机制,如Binder、AIDL(Android Interface Definition Language)以及...
Android的基本通信功能是Android系统定制的核心模块,本书主要围绕Android Telephony和融合通信两个核心部分展开。Android Telephony部分从接打电话、网络服务、数据上网三个功能解析Telephony。 全书共10章,主要...
3. **Android应用程序框架**:包括Activity管理、Intent机制、Service、BroadcastReceiver、ContentProvider等关键组件,它们构成了Android应用的基本架构。理解这些组件的工作流程和交互方式,能帮助开发者设计出更...
《深入理解Android:Telephony原理剖析与最佳实践》为经典畅销书“深入理解Android”系列新作,从源码角度深入解析Telephony的架构设计与实现原理,深刻揭示Android系统的通信机制! 本书是“深入理解Android”系列...
《Android系统原理与开发要点详解》是一份深入探讨Android操作系统核心机制及...通过学习,开发者不仅能掌握Android应用开发的基本技能,还能深入了解系统内部工作原理,从而在遇到问题时能更有效地进行调试和优化。
1. **Android系统概述**(01_Android系统概述.pdf):这部分内容介绍了Android的基本架构,包括其开放源码项目(AOSP)、层次结构以及与其他操作系统(如iOS)的区别。此外,还会讨论Android系统的组件,如Dalvik/...
总之,Android网络开发是一个包含多个层面的复杂主题,包括基本的网络协议、Android特有的API使用、安全性和性能优化等。开发者需要深入理解这些原理,才能在实践中编写出高效、稳定的网络应用。
根据给定的信息,我们可以深入探讨Android系统的原理与开发,特别是关于Android Service的理论与实践。 ### Android Framework概览 在Android系统中,Android Framework层扮演着核心的角色,它位于Linux内核之上,...
【Android底层原理培训课件全套(500强内部)】是针对Android系统核心机制的一套全面培训资料,涵盖了从开发环境配置到深入内核驱动的广泛内容,适合于希望深化对Android理解的专业人士。本套课程旨在帮助开发者提升...
### Android OpenGL原理分析 #### OpenGL概述 OpenGL,全称Open Graphics Library,是一种跨语言、跨平台的应用程序编程接口(API),用于渲染2D、3D矢量图形。它由一系列函数组成,允许开发者通过调用这些函数来...
最后,虽然不在指定的文件名列表中,但“Android从入门到精通.rar”通常会包含更多关于Android开发的实践指南,从基本的环境搭建、编程语言特性到应用程序的生命周期管理、权限控制、网络编程等实战技巧,全面覆盖一...
为了满足您的要求,如果有可能,请提供具有实际内容的文件部分,这样我才能根据那些信息详细说明Android系统原理及开发要点。 不过,尽管目前没有详细内容,我可以概述一些基础的Android系统原理及开发要点的知识点...
本篇文章将详细介绍Android IPC的基本概念、原理及其在Android系统中的实现方式。 #### 二、Linux系统中的IPC机制 Linux系统提供了多种进程间通信方式,包括但不限于: 1. **Socket**:提供了一种网络编程的通用...
### Android Handler运行原理详解 #### 一、引言 在Android开发中,线程间通信是非常重要的技术之一,其中Handler机制被广泛应用于实现主线程与子线程之间的数据交互。Handler机制不仅简单易用,而且功能强大,是...
首先,书中会介绍Android Telephony的基本架构,包括其主要组件如PhoneStateListener、PhoneInterfaceManager、InCallService等,以及它们之间的交互关系。PhoneStateListener用于监听电话状态的变化,如来电、去电...
Android 流量防火墙 Iptables 原理详解 Android 流量防火墙是一种基于 Iptables 的防火墙解决方案,旨在限制单个应用的联网状态。Iptables 是一个功能强大的 IP 信息包过滤系统,可以用于添加、编辑和删除规则,...
### Android开发工具及其原理 #### 一、Android Application基本概念 Android应用程序主要由一系列组件构成,其中最常见的组件是Activity。Activity可以理解为Windows系统中的窗口,用于与用户进行交互。以下是一...
本文将深入探讨Android动态换肤框架的基本原理,并结合提供的换肤源码进行分析。 首先,我们要理解Android资源系统的工作方式。Android应用的资源(如颜色、图片、布局等)被编译成二进制XML文件并打包到APK中。在...