The introduction of the Android Intent

Android Intent (Source Google Images)

Intents allow you to interact with components of the same application as well as the components that contributed by other applications.

For instance, an activity can begin external activity to photograph Image.

An Intent can contain data through Bundle. This data can be used by the receiving component.

For example: Intent allows you to divert your activity to another activity on any incident. By calling, startActivity () You can perform this task.

Intent intent = new
Intent(getApplicationContext(), SecondActivity.class);

In the above example, the foreground activity increasingly directed to other activities ()

returns the context for your foreground activity.

Type of Intent

Type on a Intent


Interest explicitly used to connect applications internal.Secara we explicitly use the name components that will be affected by intention.

For example:
If we know the name of the class then we can navigate the application of OneActivity to another activity using Intent.

Intent intent = new Intent(getApplicationContext(), SecondActivity.class);

2. Implicit:

With implicit intent, we need to specify the name of the component we only determine action to be taken and further action is handled by other application components.

Examples of basic intent is implicit open any web page

Intent intentObj = new Intent(Intent.ACTION_VIEW);

examples of Intent

Step 1: Let’s Make UI Design at the Design activity_main.xml two buttons Explicit Intent and Intent implicated.

Step 2: Create a new activity named “Second Activity”.

Step 3: Write the code in

public class MainActivity extends AppCompatActivity {
    Button explicit_btn, implicit_btn;
    protected void onCreate(Bundle savedInstanceState) {
        explicit_btn = (Button)findViewById(;
        implicit_btn = (Button) findViewById(;
        explicit_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new  Intent(getBaseContext(), SecondActivity.class);
        implicit_btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW);
        });    }}

Explicit Intent Sample

1- Designing the User Interface, Create 2 Activity & Create a text like this.

The first step

2- In Activity Secondly, Create Text with a rating of 2 Bar.

Step two

3- Coding PutExtra (): This will transfer the value of inter-activity

Third step

4- Receive Data From First Activity:

Step four

Source: Master Android (App)

Post Author: Study