Some Key Points in Android

本文深入解析了Android应用程序的各种核心组件,包括Activity、Service、BroadcastReceiver等,并详细介绍了Intent的工作原理及其在不同组件间的交互方式。此外,还探讨了如何通过IntentFilter定义组件的能力以及Activity与用户之间的交互界面。

In terms of desktop development, anActivityis equivalent to a Form. It contens UI elements that display for you, and can respond to your actions.



In AndroidManifest.xml, you have to let Android know the list of all the components that make up you application. You also have to tell the Android what's your requirements on hardware and what Permission do you want the Android to offer to you.



An intent is an abstract description of an operation to be performed.



Intent can invoke Activity, Service and BroadcastReceiver.



A BroadcastReceiverisa base class for code that will receive intents sent by sendBroadcast().



Ifregistering a receiver in your Activity.onResume()implementation, you shouldunregister it in Activity.onPause().



Using implicit Intents to request an action be performed on a piece of data, letting Android determine which application components can best service that request.


Broadcast Intents are used toannounce eventssystem-wide. you can receive them using Broadcast Receivers.



Adapters and used the to bind your presentation layer to data sources.



ListActivity is an activity that displays a list of items by binding to a data source such as an array or Cursor, and exposes event handlers when the user selects an item.



An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with setContentView(View).



An activity uses IntentFilter to let the Android knows its ability.

-Action :

SourceActivity: what kind of ablitity that the target must meet to perform this action. it tells the Android its request. (e.g.ACTION_EDIT tells the Android that the target must can edit.)

Target Activity: what kind of action that this activity can perform.(such as ACTION_CALL, ACTION_EDIT, ACTION_MAIN, etc.)

-Data : the uri of the data that the target activity will perform action on.

-Extras: like a map, we can suppose it is a excel blank that both the Source Activity can write into a key-value, and Target Activity can read by some key from it.


Every application runs in a separate process on its own instance of Dalvik VM.


It is a better way to understandIntentas arequest. It's a noun, it contains your requestion.


An Activity is an interface between the end-use and your application. The end-use communicate with your application through the it. It is a containter too, you put you view components in it.


A Handler allows you to send and process Message and Runnable objects associated with a thread's MessageQueue.


Each Handlerinstance is associated with a single thread and that thread's message queue.


Handler.post(Runnable r)
Causes the Runnable r to be added to the message queue.
The runnable will be run on the thread to which this handler is attached.


All Android application components — including Activities, Services, andBroadcast Receivers — start on the main application thread. As a result,time-consuming processing in any component will block all other componentsincluding Services and the visible Activity.


To ensure that your applications remain responsive, it’s good practice to move all slow, time-consumingoperations off the main application thread and onto a child thread.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值