# Intent Implicit

Pada praktikum kali ini kita akan mencoba implementasi beberapa operasi di Intent Implicit seperti membuka Contact, Dialpad, Camera dan browser.

![](/files/-Lj-GvHR0TI7L2jiiLpZ)

#### Buat Activity baru

Untuk dapat mengakses ke activity 3, tambahkan

![ThirdActivity](/files/-Lj-HGGnRnNvmnIVuSJs)

#### Button Activity 3&#x20;

* Untuk mengakses activity 3 ini, kita buat button baru di activity 2.

![activity\_second.xml](/files/-Lj-H_mLK2WIy3SHWbPg)

* Tampilan activity 2 akan menjadi seperti ini

![](/files/-Lj-Hl-uZJKjXxcs2Zka)

* Jangan lupa tambahkan intent pada button di activity 2 untuk perpindahan ke activity 3.

![](/files/-Lj-IaUkznZ6PmuflU4R)

#### Desain Layout Activity 3

* Tambahkan komponen / widget button ke layout activity 3 .

{% code title="activity\_third.xml" %}

```
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="16dp"
    tools:context=".ThirdActivity">

    <EditText
        android:id="@+id/etNo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Enter phone no."
        android:inputType="phone"
        android:textColor="@android:color/holo_red_light" />


    <Button
        android:id="@+id/btnCamera"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Camera"
        android:textColor="@android:color/holo_red_light" />

    <Button
        android:id="@+id/btnContact"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Contact"
        android:textColor="@android:color/holo_red_light" />

    <Button
        android:id="@+id/btnBrowser"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Browser"
        android:textColor="@android:color/holo_red_light" />

    <Button
        android:id="@+id/btnGallery"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Gallery"
        android:textColor="@android:color/holo_red_light" />

    <Button
        android:id="@+id/btnDial"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Dialpad"
        android:textColor="@android:color/holo_red_light" />

</LinearLayout>

```

{% endcode %}

#### Logic di Activity 3

```
public class ThirdActivity extends AppCompatActivity implements View.OnClickListener {

    Button btnCamera, btnContact, btnBrowser, btnGallery, btnDial;

    EditText etNo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_third);

        etNo = findViewById(R.id.etNo);

        btnCamera = findViewById(R.id.btnCamera);
        btnBrowser = findViewById(R.id.btnBrowser);
        btnGallery = findViewById(R.id.btnGallery);
        btnDial = findViewById(R.id.btnDial);
        btnContact = findViewById(R.id.btnContact);


        btnDial.setOnClickListener(this);
        btnCamera.setOnClickListener(this);
        btnBrowser.setOnClickListener(this);
        btnContact.setOnClickListener(this);
        btnGallery.setOnClickListener(this);


    }

    @Override
    public void onClick(View view) {

        switch (view.getId()) {
            case R.id.btnDial:
                Intent i = new Intent();
                i.setAction(Intent.ACTION_DIAL);
                i.setData(Uri.parse("tel:" + etNo.getText()));
                startActivity(i);
                break;

            case R.id.btnCamera:
                Intent iCamera = new Intent();
                iCamera.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
                startActivity(iCamera);
                break;

            case R.id.btnGallery:
                Intent iGallery = new Intent();
                iGallery.setAction(Intent.ACTION_VIEW);
                iGallery.setData(Uri.parse("content://media/external/images/media/"));
                startActivity(iGallery);
                break;

            case R.id.btnBrowser:
                Intent iBrowser = new Intent();
                iBrowser.setAction(Intent.ACTION_VIEW);
                iBrowser.setData(Uri.parse("http://www.google.com/"));
                startActivity(Intent.createChooser(iBrowser, "Title"));
                break;

            case R.id.btnContact:
                Intent iContact = new Intent();
                iContact.setAction(Intent.ACTION_VIEW);
                iContact.setData(Uri.parse("content://contacts/people/"));
                startActivity(iContact);
                break;

            default:
                break;
        }
    }
}
```

#### Jalankan Aplikasi anda

![](/files/-Lj-IkXSLcZoPKQFVpsJ)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dtspens.gitbook.io/dts-pens/fundamental/intent/intent-implicit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
