Intent Objects Used in Inter Process Communication

We'll start with how the client makes a request. Several classes are involved:

Activity and Context

We've seen Activity objects used throughout this book. The Context class, a parent class of Activity and Service, contains the methods for sending Intent objects from one Activity object to another, whether in the same process or a different one. So every place you have an Activity subclass— which is nearly every place in your application that needs to display a UI—you have the methods for slinging Intent objects around to other Activity instances elsewhere in the Android system. Intent

Intent objects are passed from process to process, using methods such as startActivity and startActivityForResult.

The Intent class itself provides constructors, accessors, and other utilities for handling the content of an Intent object, but no methods for moving Intent objects. An important set of accessors are those named putExtra. Several methods with this name and different arguments—hence different signatures—let you attach "extra" data to an Intent. This data can be used for general-purpose inter-process communication. The first examples in this chapter will use this kind of simple interprocess communication.

0 0

Post a comment