The Overview of Android Application Development

The Overview of Android Application Development


Android's Concepts


Android applications consist of loosely tied components.
Developers can tie their components to pre-defined events called intents.

There are four main types of components:

  • Activities: Activities are the main building block in an Android app, activities always take the entirety of the visual area and are made to be stacked on top of one another, allowing the user to go back to where he was previously. Typically, the user will start from a particular activity and move through several others and end up creating a stack of activities all related to the original one they launched; this stack of activities is called a task. The user can then switch to another task by clicking the Home button and starting another activity stack from the app launcher.

  • Services: Android services are similar to background processes or daemons in the Unix world. Essentially, a service is activated when another component requires its services and typically remains active for the duration required by its caller.
  • Broadcast receivers: Broadcast receivers are similar to interrupt handlers. When a key event occurs, a broadcast receiver is triggered to handle that event on the app’s behalf.
  • Content providers: Content providers are essentially databases which  make data accessible to other apps.

Think of intents as Unix signals, but the intent itself is a passive object. The effects of its dispatching will depend on its content, the mechanism used to dispatch it, the system’s built-in rules, and the set of installed

apps. 
Components can be declared as capable of dealing with given intent types using filters in the manifest file. The system will thereafter match intents to that filter and trigger the corresponding component at runtime. This is typically called an “implicit” intent. An intent can also be sent to a specific component in an “explicit” fashion, bypassing the need to declare that intent within the receiving component’s filter.

Android defines a standard lifecycle for each component type. An app developer must manage her components lifecycle by implementing a series of callbacks for each component. These callbacks are then triggered by events related to the component lifecycle.


Manifest file informs the system of the app’s components, the capabilities required to run the app, the minimum level of the API required, any hardware requirements, etc. The manifest is formatted as an XML file and resides at the topmost directory of the app’s sources as AndroidManifest.xml.

Whenever an app’s component is activated, a process will be started to house that app’s components. all other components of that app that start after the initial component is activated will run within the same process as that component. In other words, all components of an app are contained within a single Linux process.

Android defines its own RPC/IPC(remote procedure call/inter-process communication) mechanism: Binder. Components use the in-kernel Binder mechanism, accessible through /dev/binder
App developers, however, do not use the Binder mechanism directly. Instead, they must define and interact with interfaces using Android’s Interface Definition Language (IDL). Interface definitions are usually stored in an .aidl file and are processed by the aidl tool.

Android's Framework

  • User interface:  All UI objects in Android are built as descendants of the View class and are organized within a hierarchy of ViewGroups. An activity’s UI is displayed when its content is set as the root of a ViewGroup hierarchy.
  • Data storage: Android presents developers with several storage options: shared preferences, files and SQLite.
  • Security and permissions: Security in Android is enforced at the process level. Every app installed gets its own UID and group identifier (GID). Essentially, it’s as if every app is a separate “user” in the system. In effect, each app lives in its own separate sandbox. To exit the sandbox and access key system functionality or resources, apps must use Android’s permission mechanisms, which require developers to statically declare the permissions needed by an app in its manifest file. When an app is installed, the user is prompted to approve the permissions required to run an app. 

App Development Tools


The ADT Bundle(http://developer.android.com/sdk/index.html) includes everything you need to begin developing apps:
  • Eclipse + ADT plugin
  • Android SDK Tools
  • Android Platform-tools
  • The latest Android platform
  • The latest Android system image for the emulator


留言

熱門文章