有很多说Activity是一个容器,我觉得不是,按照英语的翻译可能更好,是一个活动,而这个活动中存在着各种组件,这些组件只是摆在Activity中供用户操作和可见的。
但是所有组件的基础是在一个Activity上运行的。
那么如果在一个程序中有多个Activity时,在程序启动时应该是执行的那个Activity呢?
An intent is an abstract description of an operation to be performed.
The primary pieces of information in an intent are:
action -- The general action to be performed, such as ACTION_VIEW
,ACTION_EDIT
,ACTION_MAIN
, etc.
data -- The data to operate on, such as a person record in the contacts database, expressed as aUri
.
In addition to these primary attributes, there are a number of secondary attributes that you can also include with an intent:
category -- Gives additional information about the action to execute.
type -- Specifies an explicit type (a MIME type) of the intent data. Normally the type is inferred from the data itself. By setting this attribute, you disable that evaluation and force an explicit type.
component -- Specifies an explicit name of a component class to use for the intent. Normally this is determined by looking at the other information in the intent (the action, data/type, and categories) and matching that with a component that can handle it. If this attribute is set then none of the evaluation is performed, and this component is used exactly as is. By specifying this attribute, all of the other Intent attributes become optional.
extras -- This is a Bundle
of any additional information. This can be used to provide extended information to the component. For example, if we have a action to send an e-mail message, we could also include extra pieces of data here to supply a subject, body, etc.
以上引自android官网:http://developer.android.com/reference/android/content/Intent.html#ACTION_MAIN
在其中可以找到:
Should be displayed in the top-level launcher.
Activity Action: Start as a main entry point, does not expect to receive data.
Input: nothing
Output: nothing