Summary:Activity, Intents, and Tasks,Service,Content provider

-Android introduces a richer and more complex approach by supporting multiple application entry points. Android programs should expect the system to start them indifferent places, depending on where the user is coming from and what she wants todo next

Activity, Intents, and Tasks

-An Android activity is both a unit of user interaction—typically filling the wholescreen of an Android mobile device—and a unit of execution

-The unit of communication is the Intent class. An Intent represents anabstract description of a function that one activity requires another activity to perform,such as taking a picture.

public class TestActivity extends Activity {/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}}
-The onCreate method kicks off the lifecycle of the Activity
-An Activity interactswith the Android runtime to implement key aspects of the application life cycle. Eachactivity can also be independently configured, through a Context class

-Each activity in an Android application is largely separate from other activities. Thecode that implements one activity does not directly call methods in the code that implements another activity.

-Instead of a user interface flow control based on method calls, applications describe anIntent that they want to execute and ask the system to find one that matches.


Service

-The Android Service class is for background tasks that may be active but not visibleon the screen.

-The Android platform avoids reclaiming service resources, soonce a service starts, it is likely to be available unless memory gets extremelyconstrained.

Content provider

-Content provider components are roughly analogous to a RESTful web service: youfind them using a URI, and the operations of a ContentProvider subclass parallelRESTful web operations such as putting and getting data.

-REST stands for “Representational State Transfer.”

-Content provider components are the heart of the Android content model: by providinga ContentProvider , your application can share data with other applications and managethe data model of an application.

-A companion class, ContentResolver , enables othercomponents in an Android system to find content providers.

-Due to its importance in Android, we provide a brief introduction here to writing aclient that uses a content provider

-Activities access specific content provider instancesusing the ContentResolver class and associated URLs as follows:

// code from an activity methodContentProviderClient client = getContentResolver().acquireContentProviderClient("content://contacts/people");ContentProvider provider = client.getLocalContentProvider();
-Together with the Activity component of an Android application, content providersprovide the necessary parts of a Model-View-Controller (MVC) architecture.



更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. 浅谈android的selector,背景选择器
  2. Android(安卓)动画详解
  3. 【Android】从无到有:手把手一步步教你使
  4. Android(安卓)Binder简介
  5. Android中AppWidget加载流程(一)
  6. Android(安卓)之 ServiceManager与服务管
  7. [置顶] android 实现APK之间的跳转
  8. Android上传图片到服务器,android-async-h
  9. Android(安卓)混合了 JSON 的 Android(安
  10. Intent(open file) android