In Android the reuse of other application components is a concept known as task. An application can access other Android components to achieve a task. For example, from a component of your application you can trigger another component in the Android system, which manages photos, even if this component is not part of your application. In this component you select a photo and return to your application to use the selected photo.
Such a flow of events is depicted in the following graphic.
Intents are asynchronous messages which allow application components to request functionality from other Android components. Intents allow you to interact with components from the same applications as well as with components contributed by other applications. For example, an activity can start an external activity for taking a picture.
Intents are objects of the
android.content.Intent type. Your code can send them to the Android system defining the components you are targeting. For example, via the
startActivity() method you can define that the intent should be used to start an activity.
An intent can contain data via a
Bundle. This data can be used by the receiving component.
To start an activity, use the method
startActivity(intent). This method is defined on the
Context object which
The following code demonstrates how you can start another activity via an intent.
# Start the activity connect to the # specified class Intent i = new Intent(this, ActivityTwo.class); startActivity(i);
Activities which are started by other Android activities are called sub-activities. This wording makes it easier to describe which activity is meant.
Android supports explicit and implicit intents.
An application can define the target component directly in the intent (explicit intent) or ask the Android system to evaluate registered components based on the intent data (implicit intents).
Explicit intents explicitly define the component which should be called by the Android system, by using the Java class as identifier.
The following shows how to create an explicit intent and send it to the Android system. If the class specified in the intent represents an activity, the Android system starts it.
Intent i = new Intent(this, ActivityTwo.class); i.putExtra("Value1", "This value one for ActivityTwo "); i.putExtra("Value2", "This value two ActivityTwo");
Explicit intents are typically used within on application as the classes in an application are controlled by the application developer.
Implicit intents specify the action which should be performed and optionally data which provides content for the action.
For example, the following tells the Android system to view a webpage. All installed web browsers should be registered to the corresponding intent data via an intent filter.
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.vogella.com")); startActivity(i);
If an implicit intent is sent to the Android system, it searches for all components which are registered for the specific action and the fitting data type.
If only one component is found, Android starts this component directly. If several components are identified by the Android system, the user will get a selection dialog and can decide which component should be used for the intent.
a) This course is specially designed to provide technical knowledge and skills to cope with the requirement of Android Developer occupations of the Mobile sector. The course will be implemented to ensure at least 80% of total contact hours on practical/hands on skills training or practice and 20% trade/ occupations related theory including OHS and soft modules;
b) The course is designed to enable trainees to acquire a range of technical and vocational, practical, personal and organizational skills valued and utilized both within and beyond the workplace;
c) The course is designed to meet the required competencies of the occupations needed in the labor market in and outside the country;