app fundamentals

阅读:http://developer.android.com/guide/components/fundamentals.html 

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. For example, if your application starts the activity in the camera application that captures a photo, that activity runs in the process that belongs to the camera application, not in your application's process. Therefore, unlike applications on most other systems, Android applications don't have a single entry point (there's no main() function, for example).

  也就是说,通过调用其他程序的Activity,将使用新的进程。

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.

  程序之间不能互相调用,但是系统可以,所以必须通过intent向系统申请调用,然后由系统调用另外一个程序。

Three of the four component types—activities, services, and broadcast receivers—are activated by an asynchronous message called an intent. Intents bind individual components to each other at runtime (you can think of them as the messengers that request an action from other components), whether the component belongs to your application or another.

An intent is created with an Intent object, which defines a message to activate either a specific component or a specific type of component—an intent can be either explicit or implicit, respectively.

  四大组件,activities, services, and broadcast都可以通过intent来调用。

Before the Android system can start an application component, the system must know that the component exists by reading the application's AndroidManifest.xml file (the "manifest" file). Your application must declare all its components in this file, which must be at the root of the application project directory.

The manifest does a number of things in addition to declaring the application's components, such as:

  • 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.
  • 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.
  • And more

  必须在manifest声明所有的组件,包括:

  1、声明需要的权限;

  2、声明最低兼容的机器API等级

  3、声明所需要用到的硬件资源

  4、程序所需要连接的API库

  等等

  Activities, services, and content providers 必须在manifest声明才能被系统所识别并使用,特别的是,broadcast receivers可以在代码中动态地注册并使用。

  As discussed above, in Activating Components, you can use an Intent to start activities, services, and broadcast receivers. You can do so by explicitly naming the target component (using the component class name) in the intent. However, 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 (and optionally, the data upon which you’d like to perform the action) and allow the system to find a component on the device that can perform the action and start it. If there are multiple components that can perform the action described by the intent, then the user selects which one to use.

  intent的魔力在于,你只需要告诉intent你需要什么数据或者你要干什么,并把intent发送给系统,系统就会知道如何操作。

  系统之所以能这么做,是因为它靠的是每个程序的manifest,在组件的声明里,你可以添加上<intent-filter> 标签,使得系统知道该如何调用这个组件。

Screen size and density(For more information, see the Supporting Multiple Screens document.)

Input configurations

Device features

Platform Version

For more information about how Google Play filters applications based on these (and other) requirements, see the Filters on Google Play document.

  以上几个问题是设计程序时需要注意的几个地方。

posted @ 2013-10-19 15:57  yutoulck  阅读(190)  评论(0编辑  收藏  举报