您的位置:首页 > 移动开发

(1)The Android Application Framework Overview

2012-11-21 11:19 295 查看
The Android Application Framework

Broadcast receivers are communication components that receive messages that are sent between the Android operating system and other application components, or

between Android application components themselves.

Broadcast receivers can also use the Android NotificationManager class to alert the user via built-in phone notification methods.

Broadcast receivers are created by extending the Android BroadcastReceiver class.

To create your own content provider, you extend the ContentProvider base class, which implements a standard set of methods that are used to store and retrieve data.

Applications access the methods defined by your ContentProvider class with a ContentResolver object, which is used to talk to any content provider.

A content provider is activated when it receives a request for data from a content resolver. The other three components—activities, services, and broadcast receivers—

are activated via asynchronous messages called intents.

For activities and services, an Intent object provides an action to be taken, the data that the action needs to operate on.

(1)An activity is started up,by passing an Intent object to the Context.startActivity() method. or if it’s already started, given a new task, .The Activity class can look at the contents of the Intent object via the getIntent() method, and at subsequent
intent objects via the onNewIntent() method.

(2)An Android service component is started by passing an Intent object to the Context.startService() method, which then calls the service class onStart() method, and passes it the Intent object that contains the actions for the service to perform and the
data on which to perform them.

(3)If the service is already running and the Intent object contains new instructions, then the intent is passed to the Context.bindService() method in order to establish an open connection between the calling component and the service that is being used.
This always open, realtime connection between code modules is commonly called binding in programming.

(4)An Android broadcast receiver component is started by passing an Intent object to the Context.sendBroadcast() method, or optionally to the Context.sendOrderedBroadcast() method or Context.sendStickyBroadcast() method. The Intent object in this case contains
the message action to be taken and the data (themessage) on which that action needs to be taken.

Interactivity

Event listeners, which execute the proper code in response to an event that is triggered when a UI element is used by the user.

Intents

Intents are asynchronous messages that travel between Android’s activities, services, and broadcast receiver components.

Understanding Java SE and the Dalvik Virtual Machine

The runtime translates the Java and XML code that you write into a language that the operating system and the device understand.

The DVM is an optimization mechanism and technology that allows application code and resources to be highly optimized for use in mobile and embedded environments

When you launch an Android application, it creates a process that allocates memory and CPU processing resources (processor time slices) to the application, so that it has the resources needed to function. Each time an application
is launched and a process is spawned, an instance or copy of the DVM is launched into your Android smartphone’s memory. The DVM actually takes the Java language instructions and application's design guidelines in an XML format, along with any external resources
(images, audio files, and so on), and translates them into optimized low-level binary code that goes into the smartphone’s memory and eventually into the processor for processing.

Android smartphones are tiny Linux computers.

XML

high-density dots per inch (hdpi).

Launching Your Application: The AndroidManifest.xml File

the AndroidManifest.xml data definitions are used by Android to set up areas of system memory for application components that need to be supported. They also are used to define secure access permissions for the more sensitive
areas of Android.

interface

the public interface is a label that tells the application what this class can do, without the application needing to test its capabilities.

Bundle

Bundle, which allows us to create bundles of variables for convenience and organization.

Bundle object, which is a collection of all of the states for your activity screen UI elements. It exists so that the screen UI elements can be restored if the screen is replaced by navigation to other screens during the use
of your application.

View Class and ViewGroups class

Views have the ability to receive events.

ViewGroups are layout containers, usually collections of UI elements.

LinearLayout class, which has been subclassed from the ViewGroup class, which is subclassed from the View class, which is subclassed from the Object class.

Views use padding values and ViewGroups use margin values.

RelativeLayout:

android:layout_below="@id/label"

android:layout_alignParentRight="true"

android:layout_marginLeft="10dip"

android:layout_toLeftOf="@id/ok"

android:layout_alignTop="@id/ok"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐