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 in different places, depending on where the user was coming from an D What she wants to do next
Activity, Intents, and Tasks
-an Android activity is both a unit of user interaction-typically filling the whole screens of an Android mobile Device-and A unit of execution
-the Unit of communication is the Intent class. An Intent represents an abstract description of a function The one activity requires another activity to perform, such a s 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 life cycle of the Activity
-an Activity interacts with the Android runtime to implement key aspects of the application life cycle. Each activity can also is independently configured, through a Context class
-each activity in a Android application is largely separate from other activities. The code 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 an Intent that they want to execute and ask the system to find one, that matches.
Service
-the Android Service class is for background tasks, which may be active and not visible in the screen.
-the Android platform avoids reclaiming service resources, so once a service starts, it's likely to be available unless M Emory gets extremely constrained.
Content Provider
-content provider components is roughly analogous to a RESTful Web service:you Find them using a URI, and the operations of a ContentProvider subclass parallel RESTful Web operations such as putting and getting data.
-rest stands for "representational state Transfer."
-content provider Components is the heart of the Android Content Model:by providing a contentprovider, your applicatio n can share data with other applications and manage the data model of an application.
-A companion class, Contentresolver, enables other, the "Android system to find content providers.
-due to it importance in Android, we provide a brief introduction here to writing a client that uses a content provider
-activities Access specific content provider instances using 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 providers provide the necessary parts of a Model -view-controller (MVC) architecture.
Android Development Notes-3 (Activity, Intents, and Tasks, Service, Content provider)