ArhamTechMind

Intent in Android

An Android Intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent)or bindService(Intent, ServiceConnection, int) to communicate with a background Service.

Types of Intents

There are following two types of intents supported by Android

Intent

Explicit Intents

Explicit intent going to be connected internal world of application,suppose if you wants to connect one activity to another activity, we can do this quote by explicit intent, below image is connecting first activity to second activity by clicking button.

Explicit Intents

These intents designate the target component by its name and they are typically used for application-internal messages – such as an activity starting a subordinate service or launching a sister activity. For example −
// Explicit Intent by specifying its class name
Intent i = new Intent(FirstActivity.this, SecondActivity.class);

// Starts TargetActivity
startActivity
(i);


Implicit Intents



These intents do not name a target and the field for the component name is left blank. Implicit intents are often used to activate components in other applications. For example −

Intent read1=new Intent();
read1.setAction(android.content.Intent.ACTION_VIEW);
read1.setData(ContactsContract.Contacts.CONTENT_URI);
startActivity(read1);

Source

Leave a Comment

Your email address will not be published. Required fields are marked *