WEB开发网
开发学院手机开发Android 开发 Android Activity和Intent机制 阅读

Android Activity和Intent机制

 2010-08-14 00:33:00 来源:WEB开发网   
核心提示:ACTION_MAIN activity Start up as the initial activity of a task, with no data input and no returned output.ACTION_SYNC activity Synchronize data on a server wit

ACTION_MAIN activity Start up as the initial activity of a task, with no data input and no returned output.

ACTION_SYNC activity Synchronize data on a server with data on the mobile device.

ACTION_BATTERY_LOW broadcast receiver A warning that the battery is low.

ACTION_HEADSET_PLUG broadcast receiver A headset has been plugged into the device, or unplugged from it.

ACTION_SCREEN_ON broadcast receiver The screen has been turned on.

ACTION_TIMEZONE_CHANGED broadcast receiver The setting for the time zone has changed.

当然,也可以自定义动作(自定义的动作在使用时,需要加上包名作为前缀,如"com.example.project.SHOW_COLOR”),并可定义相应的Activity来处理我们的自定义动作。

(2)Data,也就是执行动作要操作的数据

Android中采用指向数据的一个URI来表示,如在联系人应用中,一个指向某联系人的URI可能为:content://contacts /1。对于不同的动作,其URI数据的类型是不同的(可以设置type属性指定特定类型数据),如ACTION_EDIT指定Data为文件URI,打电话为tel:URI,访问网络为http:URI,而由content provider提供的数据则为content: URIs。

(3)type(数据类型),显式指定Intent的数据类型(MIME)。一般Intent的数据类型能够根据数据本身进行判定,但是通过设置这个属性,可以强制采用显式指定的类型而不再进行推导。

(4)category(类别),被执行动作的附加信息。例如 LAUNCHER_CATEGORY 表示Intent 的接受者应该在Launcher中作为顶级应用出现;而ALTERNATIVE_CATEGORY表示当前的Intent是一系列的可选动作中的一个,这些动作可以在同一块数据上执行。还有其他的为

Constant Meaning

CATEGORY_BROWSABLE The target activity can be safely invoked by the browser to display data referenced by a link — for example, an image or an e-mail message.

CATEGORY_GADGET The activity can be embedded inside of another activity that hosts gadgets.

CATEGORY_HOME The activity displays the home screen, the first screen the user sees when the device is turned on or when the HOME key is pressed.

上一页  1 2 3 4 5 6 7  下一页

Tags:Android Activity Intent

编辑录入:coldstar [复制链接] [打 印]
赞助商链接