`

android培训文档提纲(二)

阅读更多
一、Each Activity can make an Intent call to get something done without knowing exactly who’ll receive that Intent
Android的这种调用方式,是一种各组件之间低耦合的集成方式。比如自己的应用需要调用打电话的功能,可以创建一个Intent.setAction(DIAL),请求“某一个”电话程序来完成打电话功能。如果没有安装第三方的程序,那么通常手机自带的电话程序会响应这个请求,如果安装了第三方的拨号程序(当然这种情况很少),那么就会由第三方拨号程序完成通话。而原来的Activity,对这一切是一无所知的

二、用intent来描述意图,然后用intent-filter来进行全局匹配。如果找到唯一结果,就进行调用;如果找到多个结果,则要求用户选择;如果没有找到结果,则抛出异常。手机上安装的所有程序,无论是自带的,还是第三方应用,都会参与这个匹配过程。当然,如果在manifest.xml中没有设置intent-filter,就不会参与到intent匹配。这种情况下,这种组件就只能通过显式调用被调用到

三、
Action:     Fully qualified String indicating the action (for example, android.intent.action.DIAL)
Category:   Describes where and how the Intent can be used, such as from the main
            Android menu or from the browser
Component:  Specifies an explicit package and class to use for the Intent, instead of inferring from action, type, and categories
Data:       Data to work with, expressed as a URI (for example, content://contacts/1)
Extras:     Extra data to pass to the Intent in the form of a Bundle
Type:       Specifies an explicit MIME type, such as text/plain or vnd.android.cursor.item/email_v2

四、implicit and explicit invocation。这个说的是隐式调用和显式调用

五、Android parses each <intent-filter> element into an IntentFilter object. After Android installs an .apk file, it registers the application’s components, including the Intent filters. When the platform has a registry of Intent filters, it can map any Intent requests to the correct, installed Activity, BroadcastReceiver, or Service

六、下面是intent-filter的匹配规则

Action: Each individual IntentFilter can specify zero or more actions and zero or more categories. If the action isn’t specified in the IntentFilter, it’ll match any Intent; otherwise, it’ll match only if the Intent has the same action

Category: An IntentFilter with no categories will match only an Intent with no categories; otherwise, an IntentFilter must have at least what the Intent specifies. For example,if an IntentFilter supports both the HOME and the ALTERNATIVE categories, it’ll match an Intent for either HOME or CATEGORY. But if the IntentFilter doesn’t provide any categories, it won’t match HOME or CATEGORY

Data: scheme://authority/path分别对应android:schema、android:host、android:path

七、A broadcast Intent doesn’t invoke an Activity, so your current screen usually remains in the foreground

八、Android best practices discourage long-running services. Services that run continually and constantly use the network or perform CPU-intensive tasks will eat up the device’s battery life and might slow down other operations

九、In Android, each application runs within its own process. Other applications can’t directly call methods on some service of another application, because the applications are in different sandboxes

十、If you want to allow other developers to use your weather features, you need to give them information about the methods you provide, but you might not want to share your application’s source code. Android lets you specify your IPC features by using an interface definition language (IDL) to create AIDL files

十一、Service lifecycle

SERVICE-STARTED LIFECYCLE: If you start a Service by calling Context.startService(), it runs in the background whether or not anything binds to it. If the service hasn’t been created, the Service onCreate() method is called. The onStart() method is called each time someone tries to start the service, whether or not it’s already running. Additional instances of the Service won’t be created. The Service will continue to run in the background until someone explicitly stops it with the Context.stopService() method or when the Service calls its own stopSelf() method. You should also keep in mind that the platform might kill services if resources are running low, so your application needs to be able to react accordingly

SERVICE-BOUND LIFECYCLE: If an Activity binds a Service by calling Context.bindService(), it’ll run as long
as the connection is open. An Activity establishes the connection using the Context and is also responsible for closing it. When a Service is only bound in this manner and not also started, its onCreate() method is invoked, but onStart() is not used. In these cases, the platform can stop and clean up the Service after it’s unbound

CLEANING UP WHEN A SERVICE STOPS: When a Service stops, its onDestroy() method is invoked. Inside onDestroy(), every Service should perform final cleanup, stopping any spawned threads, terminating network connections, stopping services it had started, and so on
分享到:
评论

相关推荐

    软件项目开发的全套文档提纲模板

    "软件项目开发的全套文档提纲模板"旨在提供一个结构化的框架,帮助开发者和项目经理有效地组织和编写各种必要的文档。以下是对这个提纲模板中可能包含的主要知识点的详细解释: 1. **项目启动文档**: - 项目背景...

    软件项目开发的全套文档提纲.rar

    软件项目开发的全套文档提纲 软件项目开发的全套文档提纲\项目开发总结报告(GB8567——88).doc 软件项目开发的全套文档提纲\用户手册(GB8567——88).doc 软件项目开发的全套文档提纲\操作手册(GB8567——88)....

    软件项目开发的全套文档提纲

    以下是对"软件项目开发的全套文档提纲"的详细解释: 1. **项目启动文档 (Project Initiation Document, PID)** - PID是项目的起点,它定义了项目的目标、范围、预期成果以及初步的时间线和预算。 2. **需求分析...

    软件开发项目文档提纲参考

    软件开发项目文档的应用是非常广泛的,例如,软件开发项目文档可以作为项目团队的参考文档,软件开发项目文档可以作为项目团队与客户之间的交流工具,软件开发项目文档可以作为项目团队的培训文档等。 软件开发项目...

    android底层提纲

    这个提纲主要关注的是底层部分,特别是针对ARM平台的Android移植与驱动核心开发。 1. **Android系统体系及移植相关工具** - **Android操作系统体系结构**:Android的核心包括Linux内核,负责硬件管理,以及Dalvik...

    项目开发的全套文档提纲doc

    本文将深入探讨项目开发的全套文档提纲,它们如何帮助项目顺利推进,并针对每一个核心文档提供详尽的内容解析。 首先,可行性研究报告是项目启动阶段的基石。在此阶段,项目发起人需要通过客观分析确保项目的实施...

    Intel多核培训提纲

    清华大学培训班培训提纲清华大学培训班培训提纲清华大学培训班培训提纲清华大学培训班培训提纲

    《高管财务知识培训》提纲.pdf

    《高管财务知识培训》提纲主要涵盖了财务报表的解读、财务指标分析以及绩效分析三个核心领域,旨在提升高级管理人员的财务理解和决策能力。 首先,提纲深入解析了资产负债表和利润表这两个关键财务报表。资产负债表...

    软件项目开发全套文档提纲

    "软件项目开发全套文档提纲"涵盖了软件工程中的各个重要阶段,旨在提供一个清晰、系统化的指导框架,以帮助团队成员理解项目的整体结构和各个阶段的目标。以下是对这套文档模板各部分的详细解释: 1. **项目启动...

    垃圾分类培训提纲.doc

    垃圾分类培训提纲.doc

Global site tag (gtag.js) - Google Analytics