Intent is the “message
that is passed between components” such as activities, content providers,
broadcast receivers, services etc. The dictionary meaning of intent is
intention or purpose. So, it can be described as the intention to do action.
It is mainly used to:
Ø Start the service.
Ø Launch an activity.
Ø Display a web page.
Ø Display a list of contacts.
Ø Broadcast a message.
Ø Dial a phone call etc.
Types of Intents:
There are two types of intents in android:
There are two types of intents in android:
1.
Implicit Intent.
2. Explicit Intent.
1. Implicit Intent:
Implicit Intent doesn't
specify the component (activities, content providers, broadcast receivers,
services etc). In such case, intent provides information of available
components provided by the system that is to be invoked.
For example, write the following
code to view the webpage.
Intent intent=new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("http://www.google.com"));
startActivity(intent);
intent.setData(Uri.parse("http://www.google.com"));
startActivity(intent);
2. Explicit Intent:
Explicit
Intent specifies the component. In
such case, intent provides the external class to be invoked.
For example, write the following
code to pass the information from one activity to another using explicit intent.
Intent i = new Intent(getApplicationContext(),
ActivityTwo.class);
startActivity(i);
startActivity(i);
0 comments:
Post a Comment