> For the complete documentation index, see [llms.txt](https://jobinjj.gitbook.io/tutorials/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jobinjj.gitbook.io/tutorials/basics/intents.md).

# Intents

&#x20;Each activity is started or activated with an [`Intent`](https://developer.android.com/reference/android/content/Intent.html), which is a message object that makes a request to the Android runtime to start an activity or other app component in your app or in some other app.

#### Intent types <a href="#intent-types" id="intent-types"></a>

![](/files/-L_LyBxnVKy6rIY0LiWZ)

* *Explicit intent:* You use explicit intents to start components in your own app (for example, to move between screens in the UI).
* *Implicit intent:* You do *not* specify a specific activity or other component to receive the intent. Instead, you declare a general action to perform, and the Android system matches your request to an activity or other component that can handle the requested action.

#### Implicit intent

```
Intent intent = new Intent(CurrenActivity.this, TargetActivity.class);
startActivity(intent);
```

passing extra data to next activity

```
Intent intent = new Intent(CurrenActivity.this, TargetActivity.class);
intent.putExtra("key", "this is my message");
startActivity(intent);
```

Getting data on target activity&#x20;

```
String message = getIntent.getStringExtra("key");
```

**An example for implicit intent(take picture using camera)**

Implement on onCreateView method

```
Intent pictureIntent = new Intent(
        MediaStore.ACTION_IMAGE_CAPTURE
);
    startActivityForResult(pictureIntent,
            REQUEST_CAPTURE_IMAGE);
```

override onActivityResult method

```
 @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent data) {
        if (requestCode == REQUEST_CAPTURE_IMAGE &&
                resultCode == RESULT_OK) {
            if (data != null && data.getExtras() != null) {
                imageView.setVisibility(View.VISIBLE);
                Toast.makeText(this, "got image", Toast.LENGTH_SHORT).show();
                Bitmap imageBitmap = (Bitmap) data.getExtras().get("data");
                imageView.setImageBitmap(imageBitmap);
            }
        }
    }
```


---

# 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, and the optional `goal` query parameter:

```
GET https://jobinjj.gitbook.io/tutorials/basics/intents.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
